BufferedReader.readLine() removes EOL characters automatically, and I cannot simply do a readLine() and then tack a "\r" on the end of it. I tried
InputStream myFile = new FileInputStream("C:\\test.txt");
StringBuilder sb = new StringBuilder();
int i;
while((i = myFile.read()) != -1)
{
char ch = (char) i;
sb.append(ch);
}
System.out.println(sb);
but the "char ch = (char) i" loses byte data because ints are 4 bytes while chars are 2 bytes.
I repeat, I cannot do something like
sb.append(ch+"\r");
because some files that this generic code will read will include the CR and others will not.
From java.nio.*, Files.readAllBytes(Path path) seem like an option. But I am unfamiliar with it and cannot tell if it returns EOL characters or not based off the Javadoc