Text file size limit when I use BufferedReader?
Author |
Message |
FileFantasy
|
Posted: Thu Aug 06, 2009 9:54 am Post subject: Text file size limit when I use BufferedReader? |
|
|
Hey guys, I'm just reading in a file using:
code: | File newFileName=new File("<absolute directory here>");
BufferedReader in = new BufferedReader (new InputStreamReader (new FileInputStream(newFileName.getAbsolutePath())));
|
And then I print it:
code: | String line;
ArrayList text = new ArrayList();
int lines = 0;
while((line=in.readLine())!=null)
{
text.add(line);
System.out.println (text.get(lines));
lines++;
}
in.close(); |
When my file is ~10KB, it's fine.
But when my file is ~90KB or more, the lines turn out ok, except a "box" char is added between eavery single letter,
So if the line was "Hello", it would be "☐H☐e☐l☐l☐o☐"
I'm using Eclipse.
What's wrong? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
chrisbrown
![](http://compsci.ca/v3/uploads/user_avatars/18814724584bcbb8192aae8.png)
|
Posted: Thu Aug 06, 2009 12:02 pm Post subject: RE:Text file size limit when I use BufferedReader? |
|
|
The problem is most likely due to the differences in the way Windows, Mac, and *nix handles newline characters. What operating system are you using? If you are on windows, open the file that is giving unexpected results using wordpad (not notepad), save it, then try again. The size of the file is irrelevant. |
|
|
|
|
![](images/spacer.gif) |
FileFantasy
|
Posted: Thu Aug 06, 2009 12:16 pm Post subject: RE:Text file size limit when I use BufferedReader? |
|
|
It turns out that the file was saved as a Unicode txt file. I copied/pasted it into a new txtpad and saved it as ANSI and it solved the problem.
Thanks! |
|
|
|
|
![](images/spacer.gif) |
|
|