Mam plik "plik.txt" a w nim takie wiersze z danymi pooddzielanymi średnikami
39/1;40x40x15ppi10;NT 1.1;;rt;6;2012-10-02;09:59:26;11;0;g;OK.
39/1;40x40x15ppi10;NT 1.1;;gh;6;2012-10-02;09:59:26;10,4;0;g;OK.
39/1;40x40x15ppi10;NT 1.1;;gh;6;2012-10-02;09:59:40;9,8;0;g;OK.
39/1;40x40x15ppi10;NT 1.1;;rg;6;2012-10-02;09:59:41;10,2;0;g;OK.
39/1;40x40x15ppi10;NT 1.1;;hj;6;2012-10-02;09:59:42;10,4;0;g;OK.
39/1;40x40x15ppi10;NT 1.1;;ju;6;2012-10-02;09:59:43;10,8;0;g;OK.
39/1;40x40x15ppi10;NT 1.1;;oi;6;2012-10-02;09:59:44;11;0;g;OK.
Interesuje mnie tylko 9-ta kolumna
Chciałbym aby program zapisywał ją w pliku "ala.txt"
Kompiluje się ale nie działa. Co jest nie tak?
import_ java.io.BufferedReader;
import_ java.io.FileReader;
import_ java.io.IOException;
import_ java.io.PrintWriter;
import_ java.util.ArrayList;
import_ java.util.List;
public class JavaApplication3 {
public static void main(String[] args) {
try {
FileReader fileReader = new FileReader("plik.txt");
BufferedReader bufferedReader = new BufferedReader(fileReader);
String textLine = bufferedReader.readLine();
List<String> siodmaKolumna = new ArrayList<String>();
do {
String[] podzielone = textLine.split(";");
siodmaKolumna.add(podzielone[8]);
textLine = bufferedReader.readLine();
} while (textLine != null);
bufferedReader.close();
fileReader.close();
PrintWriter zapis = new PrintWriter("ala.txt");
String newLine = System.getProperty("line.separator");
for (String s : siodmaKolumna) {
zapis.write(s + newLine);
}
zapis.close();
} catch (IOException ex) {
System.err.println("Błąd podczas odczytu / zapisu!");
}
}
}