gpt4 book ai didi

java - 如何忽略前两个字节 hdfs writeUTF 和 writeChars?

转载 作者:可可西里 更新时间:2023-11-01 16:30:56 25 4
gpt4 key购买 nike

我已经在 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 文件,然后将文件复制到本地进行一些分析。是否有替代方法来完成此任务..

最佳答案

how to ignore first two bytes hdfs writeUTF() and writeChars()?

您刚刚回答了自己的问题。使用 writeChars()

writeUTF() 只有在有人要调用 readUTF() 来读取它时才有用。它使用修改后的字符集和只有 readUTF() 才能理解的长度字。

也没有特别的理由在这里使用 DataOutputStream。如果数据都是文本,请使用 BufferedWriter。

关于java - 如何忽略前两个字节 hdfs writeUTF 和 writeChars?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32620901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com