Java examples for File Path IO:File Operation
Checking for the Existence of a File or Directory
import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; public class Main { public static void main(String[] args) { Path path = FileSystems.getDefault().getPath( "C:/folder1/folder2/folder4", "test2.txt"); boolean path_exists = Files.exists(path, new LinkOption[] { LinkOption.NOFOLLOW_LINKS }); }//from w w w.j a va 2 s . c o m }