File to String Benchmark

M. Gallant 08/15/2000

The following Java application code-snippets compare execution time in seconds for various methods of reading a local text file into a Java String object.

       System:    Win95 Dell GxPro 200 MHz  64 Mb RAM
       JVM   :    jview.exe 5.00.3309     java.exe  1.3.0-C
       File  :    2.1 Mb text file
Code Description bytecode jview.exe (sec) java.exe (sec)
Read into byte-buffer & convert to string ReadIntoStr4.class0.61.1
Read into byte-buffer & ByteArrayOutputStream ReadIntoStr2.class1.01.7
BufferedReader line at a time ReadIntoStr3.class1.72.1
Read single byte at a time ReadIntoStr1.class6277