This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes move files from one machine to another Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "move files from one machine to another" Watch "move files from one machine to another" New topic
Author

move files from one machine to another

Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
I have a file stored under directory called test on weblogic server. Weblogic is running on sun solaris machine. Now, i want to move this file from this test directory to another machine(totally a different machine to some specified directory) through java code ie., just like the way we scp from one machine to another machine on command prompt but thru java code. Is this possible? If so, please let me know how to do this, i am not too familiar with unix commands. Thanks.
Appreciate your help.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

If there's a network share in place - and you have write access to the target, you can just do a simple read/write loop. Basically, like this:

Exact format of the network file name may vary somewhat.


Customer surveys are for companies who didn't pay proper attention to begin with.
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
Hi,
This may be off on a tangent but may be useful. I'm fairly sure that you can call Ant (http://jakarta.apache.org/ant/index.html) from within java (since its written in java) and you could have an Ant task that ftps the files to the remote machine - you could also zip the files using Ant if they are large.
Cheers,
Steve
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Thanks Steve. I liked your idea of scheduling the task to Ant. I am fairly new to Ant usage, so could you please post a sample code as to how Ant ftps to the remote machine.
Thanks,
Appreciate u'r help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: move files from one machine to another
 
Similar Threads
Final Questions
File.renameTo() Failing On Solaris
moving files
Class File - Any move and/or copy method()?
How to move files in struts