aspose file tools*
The moose likes I/O and Streams and the fly likes copy file from local host to remote host Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "copy file from local host to remote host" Watch "copy file from local host to remote host" New topic
Author

copy file from local host to remote host

Thomas Houseman
Ranch Hand

Joined: Jul 30, 2009
Posts: 31
Hello,
I need to copy a simple file from local file system , to another computer on the same network.

How should i do that in a simple java program ?

Thanks !
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

Map a drive to that other host. Copy to a file on that mapped drive.
Thomas Houseman
Ranch Hand

Joined: Jul 30, 2009
Posts: 31
Paul Clapham wrote:Map a drive to that other host. Copy to a file on that mapped drive.


Thanks,
How do I do that in linux ? (both src and dest are linux).
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

There are many ways to do it in Linux, ssh, telnet, ftp, etc.

Please google the Java API for all those things.

You may want to take a look at Commons-Net.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Thomas Houseman
Ranch Hand

Joined: Jul 30, 2009
Posts: 31
Well , I tried that from winXP to winXP on another machine and it worked great :


BUT, in order to copy to a linux machine, I tried to put this as the new File :


and it doesn't work. How should I format the new File path in order to copy to a linux FS ?


Thanks !
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Linux isn't the same as Windows. You can't do it that way. If you prefer to do it that way. You need to create an NFS share and then mount it.
Thomas Houseman
Ranch Hand

Joined: Jul 30, 2009
Posts: 31
Freddy Wong wrote:Linux isn't the same as Windows. You can't do it that way. If you prefer to do it that way. You need to create an NFS share and then mount it.


I'm afraid I can't do that because I have to copy this file into an existing directory dedicated for that.
Is there any other way I can copy this simple file to a linux machine ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: copy file from local host to remote host