Tuesday, 15 February 2011

How to create a new directory using java? -


I am using the following code to create the folder but it is not making it (the output is unsuccessful) and some Do not throw exceptions.

The folder Java has already been created, I have to give the folder name and make it in the Java folder.

  Private string CreateFolder (string myfolder) {try {string Dir = "../Java/" + myfolder; Boolean result = false; File directory = new file (dir); If (! Directory.exists ()) {result = directory.mkdir (); If (result) {System.out.println ("folder is created"); Return dir; } And {return "unsuccessful"; }}} Hold (exception e) {e.printStackTrace (); } Return ""; }    

Please try to give the complete path to the directory instead of the relative path.

No comments:

Post a Comment