I am trying split some strings with ascii control characters from a text file and ultimately have the following output:
Record1
Record2
Record3
Record4
My text file looks like this in notepad++:
But when using BufferedReader
to get the line from the text file it does not catch the control characters from the file. My code looks like this:
File file = new File("Records.txt");
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader bufferedReader = new BufferedReader(isr);
String text = bufferedReader.readLine();
System.out.println(text);
and the result of my sysout looks like this:
Record1Record2Record3Record4
Should I be using ISO-8859-1 instead of UTF-8?