Creating a new folder using java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ScripterSam
    New Member
    • Oct 2007
    • 16

    Creating a new folder using java

    Hi freinds,
    Is it possible to create a new folder in a given directory using java..?
    I need to create the directory and then copy some images into the same..

    Thanks
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by ScripterSam
    Hi freinds,
    Is it possible to create a new folder in a given directory using java..?
    I need to create the directory and then copy some images into the same..

    Thanks
    Have a look at the FileSystemView class; it can create directories given
    an abstract path (a File object).

    kind regards,

    Jos

    Comment

    • ScripterSam
      New Member
      • Oct 2007
      • 16

      #3
      Thanks for the concern..
      But I need the exact implementation of the abstract function createNewFolder ..
      Please help..

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by ScripterSam
        Thanks for the concern..
        But I need the exact implementation of the abstract function createNewFolder ..
        Please help..
        The FileSystemView has a static factory method that gives you an implementation
        of the abstract FileSystemView class. Check the API documentation again.

        kind regards,

        Jos

        Comment

        • mudassar83
          New Member
          • Nov 2007
          • 9

          #5
          Originally posted by ScripterSam
          Hi freinds,
          Is it possible to create a new folder in a given directory using java..?
          I need to create the directory and then copy some images into the same..

          Thanks
          you can use filename.mkdir( ); for creating new directory.

          Comment

          • Sonal Patil

            #6
            creating a new folder using java

            Code:
            import java.io.*;
            public class FolderCreate {
            
                public static void main(String args[]){
                File f = new File("C:\\TEST");
                try{
                    if(f.exists()==false){
                        f.mkdir();
                    System.out.println("Directory Created");
                    }
                    else{
                    System.out.println("Directory is not created");
                    }
                }catch(Exception e){
                    e.printStackTrace();
                   }
                }
            }
            Last edited by MMcCarthy; Oct 28 '10, 09:08 AM. Reason: added code tags

            Comment

            Working...