Weblogic Server:使用 Java 将文件复制到网络中的共享位置
Weblogic Server: Copy files to shared location within network using Java
我们的应用部署在weblogic server 12c上。此应用程序需要将文件从服务器复制到网络位置上的某个文件夹。
如何在 Java 中实现?
应用程序代码类似于
String source =
"C:\Oracle\Middleware\Oracle_Home\user_projects\domains
\base_domain\pdf_files\ABC.pdf";//Location on server
String destination = "\machineA\SharedFolder";//shared folder in some machine on same network
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(destination);
byte[] buf = new byte[1024];
int len = 0;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
收到错误消息
java.io.FileNotFoundException: \\machineA\SharedFolder\ABC.pdf(访问被拒绝)
machineA(server) 可以作为 machineA$ 添加到共享文件夹的共享选项中。
然后来自应用程序服务器的 运行 代码将能够访问该位置。
参考:https://serverfault.com/questions/135867/how-to-grant-network-access-to-localsystem-account
我们的应用部署在weblogic server 12c上。此应用程序需要将文件从服务器复制到网络位置上的某个文件夹。 如何在 Java 中实现?
应用程序代码类似于
String source =
"C:\Oracle\Middleware\Oracle_Home\user_projects\domains
\base_domain\pdf_files\ABC.pdf";//Location on server
String destination = "\machineA\SharedFolder";//shared folder in some machine on same network
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(destination);
byte[] buf = new byte[1024];
int len = 0;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
收到错误消息 java.io.FileNotFoundException: \\machineA\SharedFolder\ABC.pdf(访问被拒绝)
machineA(server) 可以作为 machineA$ 添加到共享文件夹的共享选项中。 然后来自应用程序服务器的 运行 代码将能够访问该位置。
参考:https://serverfault.com/questions/135867/how-to-grant-network-access-to-localsystem-account