I have a .txt file that is read from which I need to take apart in several words
PRU.U,
PRU.D,
EJEM.T,
EJEM.C
For example that pru
is equal to prueba
and that u
is uno
And so on each one with their respective words, but I do not know how to use split
or stringtokenizer
// This would be an example of the text that reads
Ademasde
PRU.U,
//
PRU.D,
//
EJEM.T,
//
EJEM.C
a
Scanner input;
try{
input = new Scanner(new File("C:\Users\USUARIO\Desktop\EJEMPLO.txt"));
while (input.hasNextLine()) {
String line = input.nextLine();
String[] ON = line.split("\stu.");
for (int x = 0; x < ON.length; x++) {
String Tabla = "EJEMPLO ";
System.out.println(Tabla + ON[x].replace(",", ""));
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}