public void scanFile(byte[] fileBytes, String fileName)
throws IOException, Exception {
if (scan) {
AVClient avc = new AVClient(avServer, avPort, avMode);
if (avc.scanfile(fileName, fileBytes) == -1) {
throw new VirusException("WARNING: A virus was detected in
your attachment: " + fileName + "<br>Please scan
your system with the latest antivirus software with
updated virus definitions and try again.");
}
}
}
然后
catch (Exception ex) {
logger.error(ex);
if (ex instanceof VirusException) {
// do something here
}
else {
// there was some other error – handle it
}
}
3 回答
使用以下代码 .
Commnad线对你来说是更好的选择 . 然后读取日志文件来解决问题 .
我只是google了一下,发现一篇有趣的文章看看here
快速参考:
然后
在Java和Go中使用VirusTotal Public API V2.0实现VIGHNESWAR RAO
可在https://vighnesh.me/virustotal获取
它具有丰富的功能来扫描文件,URL,域,IP地址,并获得有关扫描的详细报告 .
使用此API,您的文件将使用56个防病毒引擎进行扫描 . 并且所有防病毒引擎都在virustotal Cloud 中运行,因此您无需维护或运行任何防病毒引擎 .
此API的一个重要特性是它具有接受java.io.FileInputStream或java.io.File作为参数的方法 .
所有API功能都通过示例清楚地解释 .
使用这个API
步骤1:在http://virustotal.com(VirusTotal,Google的子公司)中创建一个帐户并获取API密钥(100%免费)
步骤2:访问https://vighnesh.me/virustotal并下载所需的jar文件
第3步:只使用API提供的方法 .
您可以使用https://vighnesh.me/virustotal/Java/examples.html或https://vighnesh.me/virustotal/Go/examples.html中提供的示例