aspose file tools*
The moose likes I/O and Streams and the fly likes Strange behaviour of SequenceInputStream with UTF-16 Encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Strange behaviour of SequenceInputStream with UTF-16 Encoding" Watch "Strange behaviour of SequenceInputStream with UTF-16 Encoding" New topic
Author

Strange behaviour of SequenceInputStream with UTF-16 Encoding

cohen schingis
Greenhorn

Joined: Oct 12, 2012
Posts: 1
I tried to create a SequenceStream of UTF-16 encoded files.




if i run this i got this as output:



if i run it, with only one File it works fine:



output:



Where are the Questionsmarks from? how can i handle this?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Welcome to the Ranch, cohen!

It looks to me like the last line in each of the files doesn't have a line-ending character, so when you concatenate the three files, the last line of File 1 and the first line of File 2 look like one line of text. That would at least explain why they are combined that way.

As for the question mark, it looks to me like each of the file has some bytes at the end which (as we already saw) aren't line-endings, but instead are some other character which can't be represented as text.

I would suggest you look at the files to see what's actually happening. A hex editor might be better than an ordinary text editor to do that, since the text editor might hide the file trailer character from you.
 
Don't get me started about those stupid light bulbs.
 
subject: Strange behaviour of SequenceInputStream with UTF-16 Encoding