Created
July 16, 2014 02:48
-
-
Save cjmcgraw/202ae95f8f3fe9a346ee to your computer and use it in GitHub Desktop.
Class for obtaining and validating a file path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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