まず、インストールされているウイルス対策ソフトウェアが提供する API の種類を確認する必要があります。
提供されている Java API (AVG API など) がある場合は、以下のように使用する必要があります。
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.");
}
}
}
インストールされているウイルス対策ソフトウェアで Java API が提供されていない場合でも、以下のようにコマンド ラインを使用して呼び出すことができます。
String[] commands = new String[5];
commands[0] = "cmd";
commands[1] = "/c";
commands[2] = "C:\\Program Files\\AVG\\AVG10\\avgscanx.exe";
commands[3] = "/scan=" + filename;
commands[4] = "/report=" + virusoutput;
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(commands);
参照用の興味深い記事があります: JEE アプリケーションでのウイルス対策ファイル スキャンの実装
これがお役に立てば幸いです。