Andromeda
Andromeda

Reputation: 12897

Java file copy from one server to another

I want to copy one file from system1 to system2. both these system are in the same network. the file is present in a shared folder in system1. i have a username and password to access that location. how can i write a javacode to perform this?

Upvotes: 0

Views: 2759

Answers (3)

Jim
Jim

Reputation: 3284

using sockets. connect to system1. copy file, connect to system 2. paste file. voila.

An oracle tutorial on sockets

Upvotes: 0

darioo
darioo

Reputation: 47183

Does your solution have to use plain Java? If not, it would be better to use existing file transfer utilities, like scp if you're using *nix computers.

If the answer to my question is yes, then sockets are the way to go. Apache Commons libraries like net and io might also be useful.

Upvotes: 1

Lavir the Whiolet
Lavir the Whiolet

Reputation: 1016

I know how to do it under *nix only. First you have to mount both shared folders. That should do either system administrator of your computer or you can do it in your program via FUSE ("File system in user space") and appropriate Samba plugins. And then you can copy required files as usual.

Upvotes: 0

Related Questions