I am trying to copy a file from my local computer to a shared folder on a Windows server. This is the function I used.
public static void copyFileUsingJcifs(final String domain, final String userName, final String password, final String sourcePath, final String destinationPath) throws IOException { final NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, userName, password); final SmbFile sFile = new SmbFile(destinationPath, auth); final SmbFileOutputStream smbFileOutputStream = new SmbFileOutputStream(sFile); final FileInputStream fileInputStream = new FileInputStream(new File( sourcePath)); final byte[] buf = new byte[16384]; int len; while ((len = fileInputStream.read(buf)) > 0) { smbFileOutputStream.write(buf, 0, len); } fileInputStream.close(); smbFileOutputStream.close(); }
I tried this answer but did not work for me. When I do a normal copy (copy and paste), a file with a size of 25 MB requires a maximum of 8 minutes . But when I use my java program using this function, it takes more than 20 minutes . How to make this copy faster? Thanks in advance.
source share