Solved

CR or LF in readLine

Posted on 2000-04-14
4
874 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

696 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