• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading files of type data  RSS feed

 
Jennifer McAllister
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to read files of type ascii and type data in one method?
We are looping through and reading a bunch of files. Some are ascii which read fine, and others are type data. The ones of type data will not work. When you open the ones of type data they say there are so many nulls in the file. If you open the file and w! (write)it, the nulls disappear and you can then read the file. Is there a way to read this type of file without having to manually write it out?
for (int i=0; i<files.length; i++) {

File fullFile = new File(xmlin + files[i].getName());
FileReader read = new FileReader(fullFile);
BufferedReader buff = new BufferedReader(read);
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use InputStreams instead of Readers. Readers are nice in that they tranlate 8-bit characters into 16-bit Unicode based on your platform's encoding. However, if you have data mixed in, and all your text is straight ASCII anyway, then an InputStream will do the job much better.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!