The problem is that you are writing out the String "String: " and then writing out control character \r, or carriage return, and then writing out the contents.
The following version should work a bit better for you:
FileWriter fout = new FileWriter("test.txt");
fout.write("Testing|10|true|two|false\n");
fout.write("Scanner|12|one|true|");
fout.close();
FileReader fin = new FileReader("test.txt");
Scanner src = new Scanner(fin).useDelimiter("[|\n]");
To really see what I am talking about with the \r, you should change your original program so the print code looks like this:
} else {
str = src.next().trim();
str = str.replace('\n', '_');
str = str.replace('\r', '_');
System.out.println("String: " + str);
}
You should see the output:
String: false__Scanner