I have a little problem.
Here is my code
package email;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.FileChooser;
public class Controller {
@FXML
public static Label daten;
@FXML
public static Button Datei;
@FXML
public TextField Trennzeichen;
static int i = 0;
@FXML
public void Datei(ActionEvent event) throws IOException, InterruptedException {
FileChooser fileChooser = new FileChooser();
File file = fileChooser.showOpenDialog(null);
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
fileChooser.getExtensionFilters().add(extFilter);
String[] buffer = new String[9];
String[][] data = new String[2000][9];
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String zeile = reader.readLine();
while (zeile != null) {
if ((zeile.substring(0, 1).equals("I")) || (zeile.substring(0, 1).equals("-"))) {
System.out.println("ha");
} else {
buffer = zeile.split(Trennzeichen.getText());
for (int t = 0; t < buffer.length; t++) {
data[i][t] = buffer[t];
}
++i;
daten.setText("" + i);
}
zeile = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
I have a Label on my GUI, thats have to show me how many lines are in my txt file.
This works fine, but it is not live, the gui update after the work, before is the gui freezy..
How can I fix this in a task?
short again:
I have 1 label filechooser thats load a txt file the label have to show how many lines are reading after every line