Possible Duplicate: How to create a Java String from the contents of a file Whole text file to a String in Java
You can try using Scanner if you are using JDK5 or higher.
Scanner scan = new Scanner(file); scan.useDelimiter("\\Z"); String content = scan.next();
Or you can also use Guava
String data = Files.toString(new File("path.txt"), Charsets.UTF8);