Added file and device verification
This commit is contained in:
@@ -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)");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user