Thursday, 21 February 2013

Creating a Directory using Java

It is often a good idea to have a directory to store your application's data .
Here you can see how you can build your application to create the directory for you.


//Let's do the import first....


public class CreateADirectory  {
public static void main(String args[]) {

// Specify the directory's name and location
File ourDirectory = new File("C://Test ");

Create the Directory if not exists     

//Catch exception if any
  }catch (Exception e){
  System.err.println("Error: " + e.getMessage());

// when this program runs it creates the Directory Test 

No comments:

Post a Comment