Solved

RandomAccessFile.readLine() has carriage return

Posted on 1998-10-22
3
632 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

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

Title # Comments Views Activity
java. non-English characters encoding problem. intellij idea 3 74
mockito example issue 8 62
GUI builder for Eclipse? 8 27
Java Loop 6 49
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…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

920 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