How to move files?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roshan Rokade
    New Member
    • Oct 2011
    • 1

    How to move files?

    hi,
    I want java code to move multiple files from one folder of one server to another folder of another server.
    source folder is in windows & target folder is in linux server.
    if anyone knows.please help me.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Of course there are experts here who know how to move files :)

    Your question is too vague and large to answer. You need to attempt to solve this problem before asking the experts here for help with the topic. That way we can help you more easily.

    To move a files from somewhere to somewhere else you need to:
    1. open the directory that contains the files that are to be moved
    2. loop through the contents of the directory and for each file that you want to move do the following:
      1. copy the file that you want to move into memory
      2. create a new file (using the same name as the file you have copied into memory) in the new directory
      3. write the file's contents into the new file
      4. delete the original file (in the old directory)
      5. close all file handlers/connections
    3. close any directory handlers/connections that you were using


    So what you need to do is research what classes are required in order to open a directory and work with files.

    -Frinny
    Last edited by Frinavale; Oct 14 '11, 03:38 PM.

    Comment

    Working...