Alles.
I did fix your shit.
This commit is contained in:
parent
bfe88db9c4
commit
fd37c39e11
@ -1,9 +1,6 @@
|
||||
package application;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
@ -17,17 +14,10 @@ public class Main extends Application {
|
||||
try {
|
||||
RootBorderPane root = new RootBorderPane();
|
||||
Scene scene = new Scene(root,400,400);
|
||||
primaryStage.setAlwaysOnTop(true);
|
||||
// primaryStage.setAlwaysOnTop(true);
|
||||
primaryStage.setTitle("Rechner");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
|
||||
Button btImport = new Button("Select File");
|
||||
btImport.setOnAction(e -> {
|
||||
File selectedFile = fileChooser.showOpenDialog(primaryStage);
|
||||
});
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -4,13 +4,11 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
public class RootBorderPane extends BorderPane {
|
||||
@ -28,7 +26,7 @@ public class RootBorderPane extends BorderPane {
|
||||
private void initComponents() {
|
||||
title = new Label("Do stuff");
|
||||
tfInput = new TextField();
|
||||
btInput = new Button("Abesnden");
|
||||
btInput = new Button("Absenden");
|
||||
btImport = new Button("Importieren");
|
||||
gpInput = new GridPane();
|
||||
|
||||
@ -49,35 +47,29 @@ public class RootBorderPane extends BorderPane {
|
||||
}
|
||||
|
||||
public void importCSV() {
|
||||
String extension = "";
|
||||
String fileName = "";
|
||||
String filePath = "";
|
||||
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
File selectedFile = fileChooser.showOpenDialog(null);
|
||||
|
||||
|
||||
File Readfile = selectedFile;
|
||||
if (Readfile.exists()) {
|
||||
String FileName = Readfile.getName();
|
||||
String FilePath = Readfile.getAbsolutePath();
|
||||
|
||||
int index = FileName.lastIndexOf('.');
|
||||
if (index > 0) {
|
||||
extension = FileName.substring(index + 1);
|
||||
}
|
||||
System.out.println(extension);
|
||||
|
||||
File readfile = selectedFile;
|
||||
if (readfile.exists()) {
|
||||
fileName = readfile.getName();
|
||||
filePath = readfile.getAbsolutePath();
|
||||
} else {
|
||||
System.out.println("The file does not exist.");
|
||||
}
|
||||
|
||||
if(extension == "txt") {
|
||||
if(fileName.endsWith(".csv")) {
|
||||
try {
|
||||
File file = selectedFile;
|
||||
Scanner myReader = new Scanner(file);
|
||||
String data = "";
|
||||
while (myReader.hasNextLine()) {
|
||||
String data = myReader.nextLine();
|
||||
System.out.println(data);
|
||||
data += myReader.nextLine();
|
||||
}
|
||||
System.out.println(data);
|
||||
myReader.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("An error occurred.");
|
||||
|
Loading…
Reference in New Issue
Block a user