我已经用hdfs写了一些数据,但是我希望它没有writeutf()方法写的前两个字节。我想把第一个两字节空闲的hdfs文件复制到本地文件,并对其进行一些分析。
if (fs.exists(filenamePath)) {
// remove the file first
//fs.delete(filenamePath);
out = fs.append(filenamePath);
}
// create if file doesnt exists
else{
out = fs.create(filenamePath);
}
out.writeUTF(getFeaturesString(searchCriteriaList,fileNameData));
out.close();
写入的数据如下
0aEX Series ex4200-24f....
我只想
EX Series ex4200-24f
我将所有数据写入hdfs文件,然后将该文件复制到本地进行分析。有没有其他方法来实现这一点。。
1条答案
按热度按时间ru9i0ody1#
如何忽略前两个字节的hdfs
writeUTF()
以及writeChars()
?你刚刚回答了你自己的问题。使用
writeChars()
.writeUTF()
只有在有人打电话时才有用readUTF()
去读它。它使用一个修改过的字符集和一个只有用户才能理解的长单词readUTF()
.没有特别的理由使用
DataOutputStream
也在这里。如果数据都是文本,请使用BufferedWriter.