We are trying to implement REST-API where the json response is received and converted into string json format. We are trying to write this string content to Mapr FS by opening stream.
FileSystem mfsHandler;
...
...
fsDataStream = mfsHandler.create(new Path("/demo/test.txt"), true);
String name = "Just to test";
byte[] namebytes = name.getBytes();
// fsDataStream.write(namebytes);
BufferedOutputStream bos = new BufferedOutputStream(fsDataStream);
bos.write(namebytes);
However, on writing the content, it is appending 8 bits making the string shift to right by 8 bits. The output is: ¬Ã^@^EJust to test
I tried following the post-http://stackoverflow.com/questions/19687576/unwanted-chars-written-from-java-rest-api-to-hadoopdfs-using-fsdataoutputstream
, but couldn't get the solution.
How to avoid this junk char? Any alternative to avoid the 8-bit right shift?