• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 885
  • Last Modified:

CR or LF in readLine

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
marss
Asked:
marss
  • 2
1 Solution
 
ovidiucraciunCommented:
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
 
kylarCommented:
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
 
ovidiucraciunCommented:
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
 
Michel PlungjanIT ExpertCommented:
Is this any help:

System.getProperty("line.separator")

Michel
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now