Advertisement
makispaiktis

14. File exists?

May 31st, 2022 (edited)
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.io.File;
  2.  
  3. public class App {
  4.  
  5.     // Main Function
  6.     public static void main(String[] args){
  7.         // I will have to put double backslashes, because \t ---> New Tab
  8.         File x = new File("C:\\Users\\thoma\\JavaProjects\\BeginnersProject14");
  9.         if(x.exists())
  10.             System.out.println("File " + x.getName() + " exists!");
  11.         else
  12.             System.out.println("File " + x.getName() + "does not exist!");
  13.     }
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement