Solved

CR or LF in readLine

Posted on 2000-04-14
4
858 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
ID: 2715650
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
ID: 2716913
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
ID: 2718798
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
ID: 2722567
Is this any help:

System.getProperty("line.separator")

Michel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

896 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

16 Experts available now in Live!

Get 1:1 Help Now