本文介绍了ByteArrayOutputStream/InputStream在S3导入时丢失换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码(伪代码为ish)...
I have the following code (pseudo code-ish)...
ByteArrayOutputStream output = new ByteArrayOutputStream();
output.write("something\n".getBytes());
output.write("something\n".getBytes());
ByteArrayOutputStream input = new ByteArrayInputStream(output.getBytes());
s3.putStream(input);
然后,当我从s3获取文件时,它看起来像是:某物.
Then when I get the file from s3 it looks like this: somethingsomething.
换行符不见了!!我不知道为什么会这样,并且互联网搜索没有帮助.有人有什么想法吗?
The newlines are gone!! I can't figure out why that is happening and internet searches have not been helpful. Does anyone have any ideas?
推荐答案
* NIX与Windows文件是常见问题.
It is common problem with *NIX vs Windows files.
尝试:"\ r \ n"而不是"\ n"
Try : "\r\n" instead of "\n"
ByteArrayOutputStream output = new ByteArrayOutputStream();
output.write("something\r\n"".getBytes());
output.write("something\r\n"".getBytes());
ByteArrayOutputStream input = new ByteArrayInputStream(output.getBytes());
s3.putStream(input);
这篇关于ByteArrayOutputStream/InputStream在S3导入时丢失换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!