Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Text file size limit when I use BufferedReader?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
FileFantasy




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
chrisbrown




PostPosted: 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.
FileFantasy




PostPosted: 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!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: