解决java读取文件乱码问题

个人笔记

private static String getFileContent(String filePath) {
		
	StringBuilder result = new StringBuilder();
    try{
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath),"UTF-8"));
        String s = null;
        while((s = br.readLine())!=null){
            result.append(System.lineSeparator()+s);
        }
        br.close();    
    }catch(Exception e){
        e.printStackTrace();
    }
    return result.toString();
		
}

 

你可能感兴趣的:(小技巧)