How to check the file string path is valid in java -
I am starting Java and I want to check if the string path available to the user is valid or not , For example if the path exists, if it does not exist and the file is not empty and etc. How can I do this?
Private static final string FILE_PATH = "com.var.file.path"; String file_path = System.getProperty (FILE_PATH, DEFAULT_FILE_PATH); A boolean has been created in the file class that will check it for you.
please:
< Code> if (new file (file_path) .exists ()) {// Do Stuff} else {System.err.println ("Error:" + File_path + "does not exist."); // or whatever other output stream you want to use}
Comments
Post a Comment