inStream = new FileInputStream(file);
long size = file.length();
MessageDigest mg = MessageDigest.getInstance("MD5");
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)
{
mg.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
{
m_byteArray = mg.digest();
String str = String.format("%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", m_byteArray[0], m_byteArray[1], m_byteArray[2], m_byteArray[3], m_byteArray[4], m_byteArray[5], m_byteArray[6], m_byteArray[7], m_byteArray[8], m_byteArray[9], m_byteArray[10], m_byteArray[11], m_byteArray[12], m_byteArray[13], m_byteArray[14], m_byteArray[15]);
if (listener != null) listener.notify(new ProgNotify(ProgNotify.END, 1000, str));
}
}
catch (FileNotFoundException ex)
{
if (listener != null) listener.notify(new ProgNotify(ProgNotify.ERROR, 0, ex.toString()));
}
catch (Exception ex)
{
if (listener != null) listener.notify(new ProgNotify(ProgNotify.ERROR, 0, ex.toString()));
}
finally
{
try
{