Reputation: 43
I am a Mac user, using Java want to copy local folder to a server folder. But I don't see the folder on the server.
package com.ch.chapp.GenericFunctionsLibrary;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
public class copyDir {
public static void main(String[] args) {
String source = "/Users/rkan/Documents/workspace/Android-CHAPPAutomationDemo/Report";
File srcDir = new File(source);
String destination = "smb://mrblk/MrBlk/AutomationTestReports/CHApp";
File destDir = new File(destination);
try {
FileUtils.copyDirectory(srcDir, destDir);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Upvotes: 1
Views: 1117
Reputation: 33093
The URL format smb://
... is only supported by the Mac desktop environment, and by Linux/Unix desktop environments such as KDE and Gnome, but not by non-desktop-aware software such as the JDK. You need to use the JCIFS library. You can find questions on Stackoverflow about how to use this library, such as this one.
Alternatively, you could mount the smb share using the mount
command-line utility, and then access it as a normal filesystem, but AFAIK the initial mount requires sudo access.
Upvotes: 1