Results 1 to 6 of 6

Thread: FoldersWork

  1. #1
    pharo is offline Member
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Default FoldersWork

    hello everyone,
    i would like to ask a question about folders
    how can i make a new folder in any directory
    and also how can i copy, cut, and paste this folder
    and also how can i copy, cut and paste files :)
    thx

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Umm. Is this a Java question?

    If so, a very good place to get ideas that might be useful in your code would be the File API documentation.

  3. #3
    pharo is offline Member
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Default yup

    thanks for replying and yes it's a Java question
    i am working on Java project
    in my class but i am a begginer to Java so i might asking the ques. in the wrong way
    mainly i want to make a folder (the same as the one of the windows) to save some files in it
    is this available in Java ?
    and if so how can i do it or what class would help me ?

  4. #4
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Thumbs up Create directory etc

    This may be to late but

    To make a directory

    Java Code:
    File f = new File("C:\\Users\\Admin\\Desktop\\javaprojects\\FolderName");
            f.mkdir(); // makes folder/directory
    To move a file and rename it

    Java Code:
    File a = new File ("C:\\Users\\Admin\\Desktop\\BmiAssignment_Notes\\mbrshipFiles\\FileToCopy.txt");
            a.renameTo(new File("C:\\Users\\Admin\\Desktop\\javaprojects\\collegeSamples\\homework\\Assessment3Bmi\\build\\classes\\assessment3bmi\\mbrshipFiles\\FileNewName.txt"));
    Hope this helps although I suspect you may have the answer by now.

  5. #5
    pharo is offline Member
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by dbashby View Post
    This may be to late but

    To make a directory

    Java Code:
    File f = new File("C:\\Users\\Admin\\Desktop\\javaprojects\\FolderName");
            f.mkdir(); // makes folder/directory
    To move a file and rename it

    Java Code:
    File a = new File ("C:\\Users\\Admin\\Desktop\\BmiAssignment_Notes\\mbrshipFiles\\FileToCopy.txt");
            a.renameTo(new File("C:\\Users\\Admin\\Desktop\\javaprojects\\collegeSamples\\homework\\Assessment3Bmi\\build\\classes\\assessment3bmi\\mbrshipFiles\\FileNewName.txt"));
    Hope this helps although I suspect you may have the answer by now.
    thanks a lot dbashby
    and itis not late and it is really very helpful
    again thanks

  6. #6
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Thumbs up

    np, glad I could help someone, I feel that I may have repaid a little of the help that I have had over last couple of months.

    :D

Posting Permissions

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