2

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);

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?

Craig
  • 1,295
  • 3
  • 16
  • 29

1 Answers1

3

It is common problem with *NIX vs Windows files.

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);
user987339
  • 10,519
  • 8
  • 40
  • 45
  • That is a good point. I'm actually writing that code on a *NIX system and then reading it in Windows. I'll give that a try, thanks. – Craig Dec 17 '13 at 23:53