Read a file as String


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. private static String readFileAsString(String filePath) throws java.io.IOException{
  2. byte[] buffer = new byte[(int) new File(filePath).length()];
  3. f.read(buffer);
  4. return new String(buffer);
  5. }

URL: http://snippets.dzone.com/posts/show/1335

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.