You need to make sure that IO is fast enough, without processing, because I suspect that processing, not IO, is slowing you down. You can get 80 MB / s from the hard drive and up to 400 MB / s from the SSD. This means that you could read everything in one second.
Try the following, which is not the fastest, but the easiest.
long start = System.nanoTime(); byte[] bytes = new byte[32*1024]; FileInputStream fis = new FileInputStream(fileName); int len; while((len = fis.read(bytes)) > 0); long time = System.nanoTime() - start; System.out.printf("Took %.3f seconds%n", time/1e9);
If you do not find that you are getting at least 50 MB / s, you have a hardware problem.
Peter Lawrey
source share