I need to use the DataInputStream, since I need the deprecated readLine() functionality and I don't know the exact file format of the input file (i.e. what line ending is used), but also need to read binary encoded primitives.
This is similar to this question:
Is there a class that exposes an unbuffered readLine method in Java?
My suggestion is to use something like this
public class SaveDataInputStream extends DataInputStream {
public SaveDataInputStream(InputStream in) {super(in);}
public String readLineSave() throws IOException {
// ???
}
}
and to use the readLine() method content that can be found in the DataInputStream class (this is similar to the accepted answer in the referred question). However I don't fully understand why the method was deprecated and would prefer to know if it is relevant for my code.
The javadoc says: This method does not properly convert bytes to characters.
But what does that mean? Should I worry about that and what could happen in the worst case? Is it possible to write my own method that fixes the issue (efficiency is not really a concern)?
Hint: new BufferedReader(new InputStreamReader(..)); is not the correct answer...