Posts

Showing posts from January, 2012

Java Convert File to String - A concise way.

File Reading Reading content of a Character file and building a final String can be done with many a mechanisms depends upon various performance considerations. A concise way would be InputStream is = new FileInputStream(new File("pathtofile")); //Acquire the stream! String content = new Scanner(is).useDelimiter("\\A").next(); // swallow it! Converting an InputStream to String concisely is String content = new Scanner(is).useDelimiter("\\A").next();