### Question:
FileUtil { public static final String readFile(File file) throws IOException { BufferedInputStream in = new BufferedInputStream(new FileInputStream(file)); SimpleByteBuffer buffer = new SimpleByteBuffer(); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) != -1) { buffer.put(buf, len); } in.close(); return new String(buffer.buffer, 0, buffer.write); } private  FileUtil(); final static String readLargeFile(File file); static final String readFile(File file);  }### Answer:
@Test(invocationCount = 4) public void testReadFile() throws Exception { Random random = new Random(9999); int iterations = 20; long before = System.nanoTime(); URL testFile = FileUtilTest.class.getResource("/text1k.txt"); File textFile = new File(testFile.toURI()); for (int i = 0; i < iterations; i++) { textFile = uncacheFile(random, textFile); FileUtil.readFile(textFile); } System.out.println("1k: " + ((System.nanoTime() - before) / 1000L / 1000L) + "ms"); textFile.renameTo(new File(testFile.toURI())); testFile = FileUtilTest.class.getResource("/text8k.txt"); textFile = new File(testFile.toURI()); for (int i = 0; i < iterations; i++) { textFile = uncacheFile(random, textFile); FileUtil.readFile(textFile); } System.out.println("8k: " + ((System.nanoTime() - before) / 1000L / 1000L) + "ms"); textFile.renameTo(new File(testFile.toURI())); testFile = FileUtilTest.class.getResource("/text96k.txt"); textFile = new File(testFile.toURI()); for (int i = 0; i < iterations; i++) { textFile = uncacheFile(random, textFile); FileUtil.readFile(textFile); } System.out.println("96k: " + ((System.nanoTime() - before) / 1000L / 1000L) + "ms"); textFile.renameTo(new File(testFile.toURI())); testFile = FileUtilTest.class.getResource("/text1m.txt"); textFile = new File(testFile.toURI()); for (int i = 0; i < iterations; i++) { textFile = uncacheFile(random, textFile); FileUtil.readFile(textFile); } System.out.println("1m: " + ((System.nanoTime() - before) / 1000L / 1000L) + "ms"); textFile.renameTo(new File(testFile.toURI())); testFile = FileUtilTest.class.getResource("/text10m.txt"); textFile = new File(testFile.toURI()); for (int i = 0; i < iterations; i++) { textFile = uncacheFile(random, textFile); FileUtil.readFile(textFile); } System.out.println("10m: " + ((System.nanoTime() - before) / 1000L / 1000L) + "ms"); textFile.renameTo(new File(testFile.toURI())); System.out.println("End testReadFile"); }