Skip to content

Instantly share code, notes, and snippets.

@cjmcgraw
Created July 16, 2014 02:48
Show Gist options
  • Save cjmcgraw/202ae95f8f3fe9a346ee to your computer and use it in GitHub Desktop.
Save cjmcgraw/202ae95f8f3fe9a346ee to your computer and use it in GitHub Desktop.
Class for obtaining and validating a file path
import java.io.*;
public class FilePathFinder {
public static void main(String[] args) {
String path = getInput();
boolean validatePath = validatePath(path);
System.out.println("Path exists? ");
System.out.println(validatePath);
}
public static String getInput() {
Console console = System.console();
return console.readLine("Enter Input ---> ");
}
public static boolean validatePath(String path) {
return new File(path).exists();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment