Added file and device verification

This commit is contained in:
Cametendo
2026-04-21 20:54:54 +02:00
parent ecb1f7be3e
commit 0edbc24003
4 changed files with 61 additions and 19 deletions

View File

@@ -1,3 +1,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Scanner;
public class FilePathAdd {
@@ -5,9 +8,25 @@ public class FilePathAdd {
public static String ImagePath = "";
protected static String filePath(Scanner UserInput) {
System.out.println("Please enter the FULL Path of your ISO / Image. ()");
ImagePath = UserInput.nextLine();
System.out.println("Using File: " + ImagePath);
return ImagePath;
fileQuestion();
while (true) {
ImagePath = UserInput.nextLine();
if (ImagePath.isBlank()) {
System.out.println("Oops.. You didn't specify a file, did you missclick?");
continue;
}
Path path = Path.of(ImagePath);
try {
Files.readAttributes(path, "basic:size");
System.out.println("Using File: " + ImagePath);
return ImagePath;
} catch (IOException e) {
System.out.println("Failed to access file, invalid path or no access to file! Please try again.");
}
}
}
protected static void fileQuestion() {
System.out.println("Please enter the FULL Path of your ISO / Image. (No tab-complete)");
}
}