Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

File is getting corrupted after scan - SymJava.jar (

Created: 22 Aug 2013 • Updated: 25 Sep 2013


I am facing an issue with Scanner Socket OutputStream. (SymJava.jar

After scanning the file(docx, csv, txt), Symantec scan engine is appending ‘0’ at the EOF which in turn causing file corruption.

Scan observations:

File Name

No of bytes before SCAN - input to the send method

No of bytes after Scan – Returned by Symantec engine




4 bytes

11 bytes

7 bytes



12573 bytes

12580 bytes

7 bytes

I believe these extra 7 bytes are causing problem and appending ‘0’ at the end. It might possible that Symantec API is writing some[7 bytes] 'end of bytes i.e. CR LF' to the SocketOutputStream which is causing the problem.


  • When I tried to  scan .txt file     - Scanner output is having ‘0’ at the end.
  • When I tried to scan .docx file   -  File is getting corrupted.

Code snippet:

try {

                     do {

                           if (bytesToRead >= buffCapRead) {

                                  buffCapRead = buff.length;

                           } else {

                                  buffCapRead = (int) bytesToRead;


                           // Refresh data buffer.

                           buff = new byte[buffCapRead];

                           bytesRead =, 0, buffCapRead);

                          // Send the bytes to Symantec Protection Engine

                           streamScanReq.send(buff, 0, buffCapRead);

                            bytesToRead = bytesToRead - bytesRead;

                     } while (bytesToRead > 0);

                     result = finishScan(streamScanReq);

              } finally {

                     if (fin != null) {

                           try {


                           } catch (IOException e) {

                                  // TODO Auto-generated catch block




                     if (output != null) {

                           try {


                           } catch (IOException e) {

                                  // TODO Auto-generated catch block




I've cross checked the inputstream and found we are passing correct no of bytes to the scanner but scanner in turn writting 7 extra bytes at the end. this behaviour is consistant for many file extensions.

Looking forward for you valuable comments and suggestions to get appropriate outputstream out of Scanner engine.



Operating Systems: