I have a simple compressor which converts a file to .zip . How can I find out the compression speed in order to print the speed ?
This is my compressor:
public class Compressor {
private static byte[] buffer = new byte[1024];
public static void compress(FileInputStream file) throws IOException {
FileOutputStream fos = new FileOutputStream("compressedFile.zip");
ZipOutputStream zos = new ZipOutputStream(fos);
ZipEntry zipEntry = new ZipEntry("file.txt");
zos.putNextEntry(zipEntry);
int len;
while ((len = file.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
file.close();
zos.closeEntry();
zos.close();
System.out.println("Done");
}
}