Check File exists or not in Java IO and Java NIO Tutorial | Java IO VS Java NIO | Java Tutorial

Published: 15 November 2020
on channel: Professor Saad
3,770
33

Like, Share, And Subscribe | Professor Saad Yousuf
Watch Our All Videos On This :    / professorsaad  
Subscribe Our Channel :    / professorsaad  
Playlists:    / ssby79  
Check Files exists or not in Java IO and Java NIO Tutorial
#JavaIO #JavaNIO #FileExistsCheck

CODE:
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class FileCheckIO {

public static void main(String[] args) {
String fname = "C:\\Users\\yousufs\\Documents\\names.txt";
Path filePath = Paths.get(fname);
if(Files.exists(filePath))
{
System.out.println("File exists!");
}
else
{
System.out.println("File does not exist!");
}

/*File f = new File(fname);
if(f.exists())
{
System.out.println("File exists!");
}
else
{
System.out.println("File does not exist!");
}*/

}

}


On this page of the site you can watch the video online Check File exists or not in Java IO and Java NIO Tutorial | Java IO VS Java NIO | Java Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Professor Saad 15 November 2020, share the link with friends and acquaintances, this video has already been watched 3,770 times on youtube and it was liked by 33 viewers. Enjoy your viewing!