Results 1 to 6 of 6
  1. #1
    newjava is offline Member
    Join Date
    Dec 2009
    Posts
    4
    Rep Power
    0

    Question Copy file from 1 dir to another dir of the same system

    Hi,

    I want to write a java program which will connect to the other system and copy the file from its one directory to another directory of the same system.


    for example:-

    | system 1 |_____________________________ > | system 2 |
    (java program) ........................................ (contains directories with files)


    system 1 contain java program.

    system 2 contain directory with file like 2/1/nature.jpg
    and empty directory 3/1/ or it will get create while running the java program.

    I want after running the java program from system 1, will copy the file from 2/1/nature.jpg to 3/1/nature.jpg of the system 2

    I am not getting how to achieve it, any idea, suggestion or code snippet will be highly appreciable.


    Thanks in Advance!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,334
    Blog Entries
    7
    Rep Power
    20

    Default

    Read the API documentation for the File, FileInputStream and FileOutputStream classes; the File class can create new directories for you (if needed) and the stream classes read and write data from and to those files; that's all you need.

    kind regards,

    Jos

  3. #3
    newjava is offline Member
    Join Date
    Dec 2009
    Posts
    4
    Rep Power
    0

    Question

    Quote Originally Posted by JosAH View Post
    Read the API documentation for the File, FileInputStream and FileOutputStream classes; the File class can create new directories for you (if needed) and the stream classes read and write data from and to those files; that's all you need.

    kind regards,

    Jos
    Hi, JosAH

    Thanks for your quick replay,
    Here my question is not to copy file from 1 dir to another dir on the system only,

    But the question is-
    I want a java program which will run on system 1 and connect system2 and copy a file from its one directory and paste it in another directory of the system2 only.


    I hope now u understand what is my requirement...

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,334
    Blog Entries
    7
    Rep Power
    20

    Default

    Your topic title is misleading then: it mentions two directories on the same system. Check out the possibilities: ftp, samba, nfs etc.

    kind regards,

    Jos

  5. #5
    renamed is offline Member
    Join Date
    Dec 2009
    Location
    Rio de Janeiro
    Posts
    38
    Rep Power
    0

    Default

    Quote Originally Posted by newjava View Post
    Hi, JosAH

    Thanks for your quick replay,
    Here my question is not to copy file from 1 dir to another dir on the system only,

    But the question is-
    I want a java program which will run on system 1 and connect system2 and copy a file from its one directory and paste it in another directory of the system2 only.


    I hope now u understand what is my requirement...
    This is not something easy... you need to use socket...

    There are several examples in google.. Though, you can try to make yours and post here any doubt you might have =)
    Please don't laugh at my English... I'm trying my best! :)

  6. #6
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default

    Well, if the two systems are networked with mapped drives would he really need the socket? I mean wouldn't he just navigate to the drive on system 2 using System 1's directory structure?

Similar Threads

  1. Replies: 10
    Last Post: 10-30-2009, 11:15 PM
  2. Copy a file to a folder.
    By leric in forum New To Java
    Replies: 7
    Last Post: 07-29-2009, 05:11 AM
  3. How to revoke permission to save or copy a PDF file in java
    By priyanka.dandekar in forum Advanced Java
    Replies: 11
    Last Post: 10-05-2008, 06:06 PM
  4. java file copy
    By hknyo in forum New To Java
    Replies: 1
    Last Post: 06-12-2008, 04:42 AM
  5. copy image/imageicon into a file on disk
    By archanajathan in forum Advanced Java
    Replies: 2
    Last Post: 11-22-2007, 06:21 AM

Posting Permissions

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