简体   繁体   English

Java文件从一台服务器复制到另一台服务器

[英]Java file copy from one server to another

I want to copy one file from system1 to system2. 我想将一个文件从system1复制到system2。 both these system are in the same network. 这两个系统都在同一网络中。 the file is present in a shared folder in system1. 该文件位于system1的共享文件夹中。 i have a username and password to access that location. 我有一个用户名和密码可以访问该位置。 how can i write a javacode to perform this? 我如何编写一个Javacode来执行此操作?

Does your solution have to use plain Java? 您的解决方案是否必须使用纯Java? If not, it would be better to use existing file transfer utilities, like scp if you're using *nix computers. 如果不是,最好使用现有的文件传输实用程序,例如,如果您正在使用* nix计算机,则使用scp

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. 诸如netio之类的Apache Commons库也可能有用。

using sockets. 使用套接字。 connect to system1. 连接到system1。 copy file, connect to system 2. paste file. 复制文件,连接到系统2.粘贴文件。 voila. 瞧。

An oracle tutorial on sockets 关于套接字的Oracle教程

I know how to do it under *nix only. 我知道如何仅在* nix下执行此操作。 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. 这应该由您的计算机的系统管理员来完成,或者您可以通过FUSE(“用户空间中的文件系统”)和适当的Samba插件在程序中完成。 And then you can copy required files as usual. 然后,您可以照常复制所需的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java-在将文件从一台服务器复制到另一台服务器之前进行过滤 - Java - Filter before copy file from one server to another 将文件从一台服务器复制到另一台服 - Copy file from one server to another 用Java将文件从一个文件夹复制到另一个文件夹 - Copy file from one folder to another in Java 在Java中将数据从一个数据库服务器复制到另一数据库服务器 - Data Copy From one db server to another db server in java 将目录,子目录和文件从一台服务器复制到Java中的另一台服务器 - Copy directories, subdirectory and files from one server to another server in java PHP / Java:如何将文件从一个文件夹复制到远程服务器内的另一个文件夹 - PHP/Java: How to copy the file from one folder into another folder inside the remote server 如何将输入数据从一个文件复制到另一个文件? 在 java - how to copy input data from one file to another one? in java Java中如何将文件属性从一个文件复制到另一个文件? - How to copy file attributes from one file to another in Java? 将文件从一台ftp服务器复制或移动到另一台ftp服务器 - copy or move a file from one ftp server to another 将一个文件从一个文件夹复制到Java中的另一个文件夹 - Copy one file from a folder to another folder in java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM