Click here to watch in Youtube :
https://www.youtube.com/watch?v=eQL5gOkZcIA&list=UUhwKlOVR041tngjerWxVccw
import java.io.File; /* *Once you have instantiated a File object we can check *if the corresponding file/dir actually exists already. */ public class FileDemo1 { public static void main(String[] args) { File file = new File("D:/work/myfile.txt"); /* * Tests whether the file or directory denoted by * this abstract pathname exists. */ boolean isExist = file.exists(); System.out.println(file.getAbsolutePath() + " is exist? = " + isExist); } }
D:\work\myfile.txt is exist? = trueFileDemo2.java
import java.io.File; /* *Once you have instantiated a File object we can check *if the corresponding file/dir actually exists already. */ public class FileDemo2 { public static void main(String[] args) { File file = new File("D:/work/"); /* * Tests whether the file or directory denoted by * this abstract pathname exists. */ boolean isExist = file.exists(); System.out.println(file.getAbsolutePath() + " is exist? = " + isExist); } }
D:\work is exist? = true
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_File_exists_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_File_exists_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/882ffbbbc9c8fbb765fb4869059bc3ee253ad31b/BasicJava/JavaIODemo_File_exists_App/?at=master
See also:
No comments:
Post a Comment