JAVA读取指定路径的文本文件并返回String


import java.io.*;

/**
 * Created by liuyikai on 2016/8/13.
 */
public class FileUtil {

    public static String LoadContentByPath(String path) throws IOException {
        InputStream is = new FileInputStream(path);
        BufferedReader in = new BufferedReader(new InputStreamReader(is));
        StringBuffer buffer = new StringBuffer();
        String line = "";
        while ((line = in.readLine()) != null){
            buffer.append(line);
        }
        return buffer.toString();

    }

}


你可能感兴趣的:(Java)