File CheckSum
public static String checkSum(String strFile)
{
// Declare variables
CheckedInputStream cCheck = null;
long lFileSize = 0;
byte[] bBuf = new byte[1024];
try
{
// Computer CRC32 checksum
cCheck = new CheckedInputStream(new FileInputStream(strFile), new CRC32());
// Get file size
lFileSize = new File(strFile).length();
// Read all file to checksum
while (cCheck.read(bBuf) >= 0)
{
}
}
catch (Exception eError)
{
System.err.println("Exception: " + eError);
return null;
}
return cCheck.getChecksum().toString();
}
{
// Declare variables
CheckedInputStream cCheck = null;
long lFileSize = 0;
byte[] bBuf = new byte[1024];
try
{
// Computer CRC32 checksum
cCheck = new CheckedInputStream(new FileInputStream(strFile), new CRC32());
// Get file size
lFileSize = new File(strFile).length();
// Read all file to checksum
while (cCheck.read(bBuf) >= 0)
{
}
}
catch (Exception eError)
{
System.err.println("Exception: " + eError);
return null;
}
return cCheck.getChecksum().toString();
}






There are currently no comments for this snippet.