String readFromFile(String strFile)
{
File file = new File(strFile);
URI uri = file.toURI();
byte[] bytes = null;
try{
bytes = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(uri));
}catch(IOException e) { e.printStackTrace(); return "ERROR loading file "+strFile; }
return new String(bytes);
}
This is Java 7 mind you. Since its new I tried this and a couple of other stuff too.
This is the fastest.
Can you do faster ?
Note: A file read by this should be able to have “no” size restriction.