Reputation: 57
I have a text file with the following contents:
23,11,12,16.5
24,23,89,111
12,23,45,89.22
I am reading it with the following code:
do {
line = fin.readLine();
System.out.println("dfg " + line);
line = fin.readLine();
System.out.println("dfg " + line);
} while (line != null);
However, I get unexpected output:
dfg {\rtf1\ansi\ansicpg1251\cocoartf1038\cocoasubrtf320
dfg {\fonttbl\f0\fmodern\fcharset0 Courier;}
How is this caused and how can I solve it?
Upvotes: 1
Views: 135
Reputation: 285405
You're trying to read an RTF (Rich Text file) file as a text file.
Solution: Don't do that. Make sure that the file is first saved as a text (txt) file before trying to read it with Java, either that or use an RTF reader (I think that some libraries for this exist, but you would have to download them and use them with your program). Is the file from WordPad? If so, be sure to save its content as text.
Upvotes: 5