RandomAccessFile.readLine() has carriage return

Posted on 1998-10-22
Medium Priority
Last Modified: 2012-05-04
i am using RandomAccessFile.readLine(); to read from a text file. each string it reads has a Carriage Return (0d hex) as the last character.

to get rid of it, i copy all but the last chararcter into new string:

tempString = file.readLine();
imageFile[i] = tempString.substring (0, tempString.length() - 1);

this isn't real pretty.
is there a better way to get what i want?
Question by:jdaues
  • 2

Accepted Solution

msmolyak earned 200 total points
ID: 1226156
Use BufferedReader.readLine() instead.

Expert Comment

ID: 1226157
That is

BufferedReader br = new BufferedReader(new FileReader(filename));
String line;
while ((line = br.readLine()) != null)

Author Comment

ID: 1226158
that seems to work, thanks!


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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

588 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