I need to be able to choose any file inside a folder by input on console.
Code
Instead of a predefined like "bridge_rgb.png"
I want to be able to choose any file in the folder via console input.
private void imageName() {
System.out.println("Select your image");
String input = scanner.next();
if (input.equals("bridge_rgb.png")) {
} else if (input.equals("gmit_rgb.png")) {
}
System.out.println("Image Selected");
}
Inside my functions I want to do the same, here's the code:
File file = new File("bridge_rgb.png");
BufferedImage source = ImageIO.read(file);
// processing: result gets created
File output = new File("bridge_grey.png");
ImageIO.write(result, "png", output);
I know a GUI would make file-choosing easy, but I have to use specifically a console.