Reading File into String when file contains null characters
Posted on 2003-10-28
Can anyone let me know how to read a file into a string when the file contains null characters inside of it. (The file data is encrypted.)
The piece of code that works is this:
File file = new File(fileName);
FileReader fr = new FileReader(file);
BufferedReader inFile = new BufferedReader(fr);
String line = infile.readLine();
Now the output of this is all fine but as soon as the file contains null characters inside of it the String does not read the file properly. Strange things happen, no errors just the println is all wrong.
I was thinking something along the lines of reading a character at a time in a loop and appending each character to the end of a String but have not been able to find out how to do that.