Loading text from a file
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class Main { public static void main(String[] argv) throws Exception { File f = new File("C:\\test.txt"); FileReader fr = new FileReader(f); BufferedReader br = new BufferedReader(fr); StringBuffer sb = new StringBuffer(); String eachLine = br.readLine(); while (eachLine != null) { sb.append(eachLine); sb.append("\n"); eachLine = br.readLine(); } System.out.println(sb.toString()); } }