skip properly (DataHelper.read confusion)

This commit is contained in:
jrandom
2005-07-27 20:15:35 +00:00
committed by zzz
parent a8a866b5f6
commit aaaf437d62

View File

@ -287,15 +287,20 @@ jP69nPbh4KLGhF+SD0+0bW4=
try {
fileInputStream = new FileInputStream(signedFile);
byte[] data = new byte[VERSION_BYTES];
int bytesRead = DataHelper.read(fileInputStream, data, Signature.SIGNATURE_BYTES, VERSION_BYTES);
if (bytesRead != VERSION_BYTES)
long skipped = fileInputStream.skip(Signature.SIGNATURE_BYTES);
if (skipped != Signature.SIGNATURE_BYTES)
return "";
byte[] data = new byte[VERSION_BYTES];
int bytesRead = DataHelper.read(fileInputStream, data);
if (bytesRead != VERSION_BYTES) {
return "";
}
for (int i = 0; i < VERSION_BYTES; i++)
if (data[i] == 0x00)
if (data[i] == 0x00) {
return new String(data, 0, i, "UTF-8");
}
return new String(data, "UTF-8");
} catch (UnsupportedEncodingException uee) {