| 15 | */ |
| 16 | public class Benchmark { |
| 17 | private static byte[] readFile(String fileName) throws IOException { |
| 18 | int bufferLength = 65536; |
| 19 | byte[] buffer = new byte[bufferLength]; |
| 20 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 21 | FileInputStream fin = new FileInputStream(fileName); |
| 22 | try { |
| 23 | int bytesRead; |
| 24 | while ((bytesRead = fin.read(buffer)) >= 0) { |
| 25 | baos.write(buffer, 0, bytesRead); |
| 26 | } |
| 27 | } finally { |
| 28 | fin.close(); |
| 29 | } |
| 30 | return baos.toByteArray(); |
| 31 | } |
| 32 | |
| 33 | private static long decodeBytes(InputStream input, OutputStream output, byte[] buffer) |
| 34 | throws IOException { |