Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: using "user.dir" with mkdir

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default using "user.dir" with mkdir

    Why can't i make a directory using "user.dir" and mkdir??? Always returns "Directory not made"

    	public static void workFlow(String input){
     
    		File input1 = new File(input);
    		System.out.println(input1.getName());
    		String fileName = input1.getName().substring(0, input1.getName().lastIndexOf("."));
     
    		File dir = new File(fileName);
    		System.out.println(dir.mkdir());
     
    		System.out.println(fileName);
    		String currentDirectory = System.getProperty("user.dir");
    		String newDirectory = currentDirectory + File.separator + fileName;
     
    		File f = new File(newDirectory);
     
    		boolean file = f.mkdirs();
     
    		System.out.println(currentDirectory);
    		System.out.println(newDirectory);
    		System.out.println(file);
     
    		if(file){
    			System.out.println("Directory made");
    			System.out.println("The current directory is: " + currentDirectory);
     
     
    		}else{
    			System.out.println("Directory not made");
    		}
     
     
    	}


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,964
    Thanks
    51
    Thanked 2,268 Times in 2,240 Posts

    Default Re: using "user.dir" with mkdir

    Is that because mkdir has already made the directory?

    Print out the full paths to each and see if they are the same.

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: using "user.dir" with mkdir

    guhhh you were right sorry for the failure on my behalf. thanks for the help

Similar Threads

  1. Java says:"Hello World". I say:"It works!"
    By Davidovic in forum Member Introductions
    Replies: 4
    Last Post: June 29th, 2010, 07:13 AM
  2. Replies: 1
    Last Post: March 15th, 2010, 10:03 PM
  3. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 07:35 AM
  4. Replies: 1
    Last Post: October 25th, 2009, 11:54 AM
  5. Replies: 4
    Last Post: August 13th, 2009, 05:54 AM