Moving a couple utility functions into BrutIO. Also, formatting change to match spec.

This commit is contained in:
Greg Leach
2015-03-25 09:56:55 -07:00
parent 472a02db41
commit 39a2848340
2 changed files with 22 additions and 24 deletions

View File

@ -17,6 +17,8 @@
package brut.util;
import java.io.*;
import java.util.zip.CRC32;
import org.apache.commons.io.IOUtils;
/**
@ -59,4 +61,20 @@ public class BrutIO {
}
return modified;
}
public static CRC32 calculateCrc(InputStream input, byte[] buffer) throws IOException {
CRC32 crc = new CRC32();
int bytesRead = 0;
while((bytesRead = input.read(buffer)) != -1) {
crc.update(buffer, 0, bytesRead);
}
return crc;
}
public static void copy(InputStream input, OutputStream output, byte[] buffer) throws IOException {
int bytesRead;
while((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
}
}