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

RandomAccessFile.readLine() has carriage return

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
jdaues
Asked:
jdaues
  • 2
1 Solution
 
msmolyakCommented:
Use BufferedReader.readLine() instead.
0
 
msmolyakCommented:
That is

BufferedReader br = new BufferedReader(new FileReader(filename));
String line;
while ((line = br.readLine()) != null)
{
.
}
0
 
jdauesAuthor Commented:
that seems to work, thanks!

0
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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