解决java读取文件乱码问题

  • Post author:
  • Post category: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();
		
}



版权声明:本文为u012890715原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。