(String fromPath, String toPath, byte[] buffer)
| 25 | } |
| 26 | |
| 27 | private static void decompress(String fromPath, String toPath, byte[] buffer) throws IOException { |
| 28 | long start; |
| 29 | long bytesDecoded; |
| 30 | long end; |
| 31 | InputStream in = null; |
| 32 | OutputStream out = null; |
| 33 | try { |
| 34 | in = new FileInputStream(fromPath); |
| 35 | out = new FileOutputStream(toPath); |
| 36 | start = System.nanoTime(); |
| 37 | bytesDecoded = decodeBytes(in, out, buffer); |
| 38 | end = System.nanoTime(); |
| 39 | } finally { |
| 40 | if (in != null) { |
| 41 | in.close(); // Hopefully, does not throw exception. |
| 42 | } |
| 43 | if (out != null) { |
| 44 | out.close(); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | double timeDelta = (end - start) / 1000000000.0; |
| 49 | if (timeDelta <= 0) { |
| 50 | return; |
| 51 | } |
| 52 | double mbDecoded = bytesDecoded / (1024.0 * 1024.0); |
| 53 | System.out.println(mbDecoded / timeDelta + " MiB/s"); |
| 54 | } |
| 55 | |
| 56 | public static void main(String... args) throws IOException { |
| 57 | if (args.length != 2 && args.length != 3) { |
no test coverage detected