hadoop读取hdfs文件中的中文乱码解决办法

来源:互联网 发布:四川广电网络机顶盒 编辑:程序博客网 时间:2024/05/29 15:10
FileSystem fs = FileSystem.get(conf);
Path file = new Path("hdfs://localhost:9000/wordcount/data/word.txt");
FSDataInputStream inStream = fs.open(file);
BufferedReader bf=new BufferedReader(new InputStreamReader(inStream));//防止中文乱码
String line = null;

while ((line = bf.readLine()) != null) {

}

如果没有红色部分,将bf.readLine()改为inStream.readLine(),中文就会乱码

0 0