Solved

RandomAccessFile.readLine() has carriage return

Posted on 1998-10-22
3
620 Views
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?
0
Comment
Question by:jdaues
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
ID: 1226156
Use BufferedReader.readLine() instead.
0
 
LVL 5

Expert Comment

by:msmolyak
ID: 1226157
That is

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

Author Comment

by:jdaues
ID: 1226158
that seems to work, thanks!

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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 …

746 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

11 Experts available now in Live!

Get 1:1 Help Now