Im trying to read from an input file using useDelimiter function. My files include "/ and \r\n" as separator. Naturally, I went for scanner.useDelimiter("/|\r\n") but the output returned is funny, specifically the first character of the file
The code is as below:
Scanner readfile = new Scanner(new File("text.txt")).useDelimiter("/|\r\");
while(readfile.hasNext()) {
System.out.println(readfile.next());
}
The input file is as below:
Dr A/P0001/N28-201/012-3465789/1
Dr B/P0002/D03-356/013-3334445/3
Dr C/SP0001/K12-311/014-9988655/4
Dr D/SP0002/T09-101/018-8888333/2
Dr E/P0003/L34-213/014-6655241/0
The output returned:
锘緿r A
P0001
N28-201
012-3465789
1
Dr B
P0002
D03-356
013-3334445
3
Dr C
SP0001
K12-311
014-9988655
4
Dr D
SP0002
T09-101
018-8888333
2
Dr E
P0003
L34-213
014-6655241
0
Can somebody help? I've been searching the internet for one whole week. Thanks in advance.