code_junkie

How to Check Path is existing or not in java

Nov 13th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. if (!new File("D:\Log\Sample").exists())
  2. {
  3. throw new FileNotFoundException("Yikes!");
  4. }
  5.  
  6. File f = new File("....");
  7. if (!f.exists()) {
  8. // The directory does not exist.
  9. ...
  10. } else if (!f.isDirectory()) {
  11. // It is not a directory (i.e. it is a file).
  12. ...
  13. }
Add Comment
Please, Sign In to add comment