Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to know a line of text file is ending with line feed or return?

807588Feb 21 2009 — edited Feb 22 2009
hi all, i have a program that read log file that generated by other service (apache http server for example), i want to know that each line is ending with "\r", "\n" or "\r\n" so i can skip them in the next time, like this:
int char_counter=0;
BufferedReader reader = new BufferedReader(new FileReader(logFileName));
while((line=reader.readLine())!=null){
       char_counter+=line.length()+x_value;
}
and the next time read the log file, i will skip all the lines that read in previous time.
BufferedReader reader = new BufferedReader(new FileReader(logFileName));
reader.skip(char_counter);
while((line=reader.readLine())!=null){
       char_counter+=line.length()+x_value;
}
with x_value is 1 or 2 depended on line end with "\n" or "\r\n".
so, how to know which is the char line ending with?

Edited by: secmask on Feb 21, 2009 5:46 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2009
Added on Feb 21 2009
9 comments
179 views