I want to remove the third value from an array I get from a text file. My text file looks like this:
item = 0 Dwarf_remains The_body_of_a_Dwarf_savaged_by_Goblins. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
item = 1 Toolkit Good_for_repairing_a_broken_cannon. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
item = 2 Cannonball Ammo_for_the_Dwarf_Cannon. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
item = 3 Nulodion's_notes It's_a_Nulodion's_notes. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
item = 4 Ammo_mould Used_to_make_cannon_ammunition. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
item = 5 Instruction_manual An_old_note_book. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Then I want to remove all these things:
The_body_of_a_Dwarf_savaged_by_Goblins.
Ammo_for_the_Dwarf_Cannon.
It's_a_Nulodion's_notes.
Used_to_make_cannon_ammunition.
An_old_note_book.
I am now using this code to get the array
import java.io.*;
public class Main {
public static void main(String [] args) {
// The name of the file to open.
String fileName = "Items.cfg";
// This will reference one line at a time
String line = null;
try {
// FileReader reads text files in the default encoding.
FileReader fileReader =
new FileReader(fileName);
// Always wrap FileReader in BufferedReader.
BufferedReader bufferedReader =
new BufferedReader(fileReader);
while((line = bufferedReader.readLine()) != null) {
String[] values = line.split("\\t");
System.out.println(values[2]);
}
// Always close files.
bufferedReader.close();
}
catch(FileNotFoundException ex) {
System.out.println("Unable to open file '" + fileName + "'");
}
catch(IOException ex) {
System.out.println("Error reading file '" + fileName + "'");
// Or we could just do this:
// ex.printStackTrace();
}
}
}
When java removed all those is it possible to save the updated file in another file, like Items2.cfg or something?