This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Line Endings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Line Endings" Watch "Line Endings" New topic

Line Endings

V Bose
Ranch Hand

Joined: Jul 10, 2003
Posts: 113
I'm trying to use the class to read from a collection of s.

Assuming I have two seperate InputStreams wrapping two seperate files that look something like -

File A:
Line 1 : Apple
Line 2 : Oranges<EOF>

File B:
Line 1 : Pears
Line 2 : Grapes<EOF>

When I try to concatenate these two streams and read them using, Line 1: Pears is never read.(Assuming the concatenation ordering is File A, File B) But if I change File A to this -
File A:
Line 1 : Apple
Line 2 : Oranges

(there is a <CR> after Oranges this time), then it works fine. Is this something to do with how <EOF>s are encoded in Windows?
Joni Salonen
Ranch Hand

Joined: Jan 07, 2006
Posts: 53
<EOF> is not a character that is present in the file. This discussion is written for C/C++ but appliest just as well in Java:

If you have problems reading past the contents of the first file, there has to be some other problem.

Can you post a small snippet of code that demonstrates your problem?
Joni Salonen
Ranch Hand

Joined: Jan 07, 2006
Posts: 53
ah, now i get it. when you concatenate the two files you end up with

because there is no line break after the last line of the first file or before the first line of the second file.
subject: Line Endings
It's not a secret anymore!