Solved

CR or LF in readLine

Posted on 2000-04-14
4
855 Views
Last Modified: 2008-02-01
is it possible to define exactly which char should end a line ?

i have a file in codepage 500 (EBCDIC) in this codepage 0D0A should be newline. but BufferedReader.readLine()wrongly uses a single 0A as delimeter aswell...

thanx
0
Comment
Question by:marss
  • 2
4 Comments
 
LVL 3

Expert Comment

by:ovidiucraciun
Comment Utility
you can avoid readline if it doesn't work like you wish.
store all chars in a StringTokenizer and let the default delimiters tab,/r,/n
0
 
LVL 4

Accepted Solution

by:
kylar earned 50 total points
Comment Utility
A StringTokenizer breaks on \r (carriage return) or \n (newline) (or a tab)  but so does the readln() method of BufferedReader. BufferedReader also looks for a \r\n at the end (return followed immediately by a newline) what you probably want to do is extend BufferedReader then override the readln() and readln(boolean b) methods, then force it to look only for a 0D0A instead of looking for single instances of 0A or 0D.

Kylar


0
 
LVL 3

Expert Comment

by:ovidiucraciun
Comment Utility
If you set the delimiter as "\r\n"
or "\n\r" (depending of how is oerdered in your case) the StringTokenizer will
break from line to line.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Is this any help:

System.getProperty("line.separator")

Michel
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Receive file in Servlet 1 36
strCopies  challenge 17 73
mapBully challenge 6 88
JUnit 4 @Before and @BeforeClass differences 3 18
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now