Here you can find the source of getReaderFor(File file)
public static DataInputStream getReaderFor(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static DataInputStream getReaderFor(File file) throws IOException { DataInputStream data;//from w w w .j a v a 2 s .co m // If the file is longer than we can fit into an array, use the slow method. if (file.length() > Integer.MAX_VALUE) data = new DataInputStream(new BufferedInputStream( new FileInputStream(file))); // Otherwise, read from a byte array, which is 4x faster on my machine. else { InputStream stream = new BufferedInputStream( new FileInputStream(file), 256); byte[] bytes = new byte[(int) file.length()]; stream.read(bytes, 0, bytes.length); stream.close(); data = new DataInputStream(new ByteArrayInputStream(bytes)); } return data; } }