Tuesday, 11 August 2009

Shortest code to read entire file

I don't remember where I had read this, but this in undoubtedly the smallest piece of code for reading the whole file.
Scanner loScanner = new Scanner(new File("C://Fazeel-C//MSS//workspace//FastTreeProj//src//sample//JSONs.txt"));
loScanner.useDelimiter("\\Z");
String wholeFile = loScanner.next();       
loScanner.close();

No comments:

Post a Comment