Results 1 to 4 of 4

Thread: How do I make a directory?

  1. #1

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    How do I make a directory using Java?

    secondly, how do I test if a directory exists already?



    Mark
    -------------------

  2. #2

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Ok,OK!
    you can all stop looking now! I've just found it!
    Mark
    -------------------

  3. #3
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Smile I would like to know..

    What is the code? id like to see it please.

  4. #4

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    This is for java executables

    Code:
    import java.io.*;
    
    //
    // Mark Sreeves July 2000
    //
    // makes a directory
    //
    
    
    public class CreateDir{
    	
    	public static void main(String[] args) throws IOException 
    	{	
    		if (args.length != 1){
    			System.out.println("usage: java CreateDir [Dir name]");
    		}else{					  
    	
    			
    			File TargetFile;
    			
    				TargetFile = new File(args[0].toString());
    		
    				if (!TargetFile.exists()){
    					TargetFile.mkdir();//if not create it
    				}
    				
    			 };
    	};
    }
    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width