0

I want to copy a file in local windows machine to another windows machine in the same LAN or Intranet using JAVA. I browsed and found that we can copy file using the copy command of ms-dos but it copies only to the shared folder of remote machine.

I don't want to copy to the shared folder but instead I want to copy to a folder inside C: drive which is not a shared one.

I tried using pscp command. It works for windows to linux file copying but not for windows to windows file copying.

Hash
  • 4,647
  • 5
  • 21
  • 39
  • Please [edit] your question to show [the code you have so far](http://whathaveyoutried.com). You should include at least an outline (but preferably a [mcve]) of the code that you are having problems with, then we can try to help with the specific problem. You should also read [ask]. – Toby Speight Jul 05 '17 at 09:11

4 Answers4

1

The best way is to send the File with an selfwritten socket application.

0

You cant copy a non shared folder. But u can write a server client application to send the data over the network:

http://www.rgagnon.com/javadetails/java-0542.html

Dennis Kriechel
  • 3,719
  • 14
  • 40
  • 62
0

As far as i know, there are several ways to achieve it.

  1. Provide two agents on the machine A and machine B, then you can copy the files to each machine by your own implement APIs.

  2. Use the winrm protocol like chef does, more detail please refer to the below link.

    You can also refer to some opensource project.

    https://github.com/cloudsoft/winrm4j
    
    https://github.com/OpenNMS/wsman
    
Xinyuan.Yan
  • 116
  • 1
  • 7
-1

You cannot copy to a folder that it is not shared.

The operating system of the computer where you want to copy files will never allow you to write wherever you want for obvious security reasons.

Jean Logeart
  • 52,687
  • 11
  • 83
  • 118