{
inStream = new FileInputStream(file);
long size = file.length();
CRC32 crc32 = null;
MessageDigest md = null;
Adler32 adler32 = null;
if (algo.equalsIgnoreCase("CRC32"))
crc32 = new CRC32();
else if (algo.equalsIgnoreCase("Adler32"))
adler32 = new Adler32();
else md = MessageDigest.getInstance(algo);
byte [] buf = new byte[BUF_SIZE];
int readed = -1;
if (listener != null) listener.notify(new ProgNotify(ProgNotify.START, 0, new Long(size).toString()));
long total = size;
boolean bAbort = false;
while(size != 0)
{
if ((readed = inStream.read(buf)) >= 0)
{
if (crc32 != null) crc32.update(buf, 0, readed);
else if (adler32 != null) adler32.update(buf, 0, readed);
else md.update(buf, 0, readed);
assert size <= readed;
size -= readed;
if (listener != null)
{
if (bAbort = listener.notify(new ProgNotify(ProgNotify.RUN, (int)(1000L - (size*1000L)/total), null)))
break;
}
}
else break;
}
if (bAbort)
{
if (listener != null) listener.notify(new ProgNotify(ProgNotify.ABORT, 0, null));
}
else
{
if (crc32 != null) m_byteArray = longToByteArray4(crc32.getValue());
else if (adler32 != null) m_byteArray = longToByteArray4(adler32.getValue());
else m_byteArray = md.digest();
int index = 0;
StringBuilder str = new StringBuilder();
String temp = null;