I have written some data in hdfs, but i want that to be without the first two bytes that the writeUTF() method writes. I want to copy this first two byte free hdfs file to local file and do some analysis on it.
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();
The data written is as follows
0aEX Series ex4200-24f....
I want only
EX Series ex4200-24f
I write all the data to hdfs file and then I am copying the file into local to do some analysis. Is there an alternative method to accomplish this..
how to ignore first two bytes hdfs
writeUTF()
andwriteChars()
?
You've just answered your own question. Use writeChars()
.
writeUTF()
is only useful when somebody is going to be calling readUTF()
to read it. It uses a modified character set and a length-word that is only understood by readUTF()
.
There's no particular reason to use DataOutputStream
here either. If the data is all text, use a BufferedWriter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.