Java code to create directory with example also to check the directory exist
|
02-06-2011, 08:46 AM
Post: #1
|
|||
|
|||
Java code to create directory with example also to check the directory exist
Java code to create directory with example also to check the directory exist using Java IO API
Find below the example code import java.io.File; public class TestCode { public static void main(String[] args) throws Exception { File dest = new File("C:/Global/Test/Sample"); if (!folderExist(dest)) { createFolder(dest); } } public static boolean createFolder(File filename) { System.out.println("createFolder:Start"); boolean makedir = filename.mkdirs(); System.out.println("createFolder:End"); return makedir; } public static boolean folderExist(File filename) { //String parent = filename.getParent(); System.out.println("folderExist:Start"); if (!filename.exists()) { System.out.println("folderExist:End"); return false; } else { System.out.println("folderExist:End"); return true; } } } |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Java code to create directory with example also to check the directory exist - tutorials4u - 02-06-2011 08:46 AM
|