Java examples for File Path IO:Text File
read File by file name and save to String
//package com.java2s; import java.io.*; public class Main { public static String readFile(String filename) { StringBuilder buf = new StringBuilder(); try {//from w w w . j a v a2s . co m BufferedReader input = new BufferedReader(new FileReader( filename)); String line; while ((line = input.readLine()) != null) { buf.append(line); buf.append(System.getProperty("line.separator")); } } catch (IOException e) { e.printStackTrace(); } return buf.toString(); } }