This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Line Endings" Watch "Line Endings" New topic
Author

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 java.io.SequenceInputStream, 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
<EOF>

(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:
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048865140&id=1043284351

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Line Endings
 
Similar Threads
ADDING TWO XML FILES
Help with choice & group tags
Adding contents of two XML's into one
How to Upload a image or video where it will be attached or keep in email?
Generic class declarations