use DataHelper.skip() in a few more places

This commit is contained in:
zzz
2013-11-10 22:20:06 +00:00
parent 3fce0e8e45
commit 69489dd19e
2 changed files with 4 additions and 11 deletions

View File

@ -170,8 +170,7 @@ class PeerAcceptor
if (b != PROTO[i])
throw new IOException("Bad protocol 0x" + Integer.toHexString(b) + " at byte " + i);
}
if (in.skip(8) != 8)
throw new IOException("EOF before hash");
DataHelper.skip(in, 8);
byte buf[] = new byte[20];
int read = DataHelper.read(in, buf);
if (read != buf.length)

View File

@ -474,9 +474,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
try {
fileInputStream = new FileInputStream(signedFile);
long skipped = fileInputStream.skip(Signature.SIGNATURE_BYTES);
if (skipped != Signature.SIGNATURE_BYTES)
return "";
DataHelper.skip(fileInputStream, Signature.SIGNATURE_BYTES);
byte[] data = new byte[VERSION_BYTES];
int bytesRead = DataHelper.read(fileInputStream, data);
@ -515,9 +513,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
*/
public static String getVersionString(InputStream inputStream) {
try {
long skipped = inputStream.skip(Signature.SIGNATURE_BYTES);
if (skipped != Signature.SIGNATURE_BYTES)
return "";
DataHelper.skip(inputStream, Signature.SIGNATURE_BYTES);
byte[] data = new byte[VERSION_BYTES];
int bytesRead = DataHelper.read(inputStream, data);
@ -640,10 +636,8 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
try {
fileInputStream = new FileInputStream(signedFile);
fileOutputStream = new FileOutputStream(outputFile);
long skipped = 0;
while (skipped < HEADER_BYTES)
skipped += fileInputStream.skip(HEADER_BYTES - skipped);
DataHelper.skip(fileInputStream, HEADER_BYTES);
byte[] buffer = new byte[16*1024];
int bytesRead = 0;