Performance: Very slow file copying to Windows network using JCIF

I'm trying to copy a file from my local machine to Shared folder in a windows server. This is the function which 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 didn't work for me. When I do normal copying(Copy and Paste) it only takes maximum of 8minutes for a 25MB file. But when I use my java program using this function its taking more than 20minutes. How can I make this copying faster? Thanks in advance.

try this function its highly optimized if its still slow then increase buffer size in code . In my case it reduced time from 10 min to copy 48MB file to 1 min

public static boolean createCopyOnNetwork(String domain,String username,String password,String src, String dest) throws Exception
{
    //FileInputStream in = null;
    SmbFileOutputStream out = null;
     BufferedInputStream inBuf = null;
    try{
        //jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords","true");
        NtlmPasswordAuthentication authentication = new NtlmPasswordAuthentication(domain,username,password); // replace with actual values  
        SmbFile file = new SmbFile(dest, authentication); // note the different format
        //in = new FileInputStream(src);
          inBuf = new BufferedInputStream(new FileInputStream(src));
        out = (SmbFileOutputStream)file.getOutputStream();
        byte[] buf = new byte[5242880];
        int len;
        while ((len = inBuf.read(buf)) > 0){
            out.write(buf, 0, len);
        }
    }
    catch(Exception ex)
    {
        throw ex;
    }
    finally{
        try{
            if(inBuf!=null)
                inBuf.close();
            if(out!=null)
                out.close();
        }
        catch(Exception ex)
        {}
    }
    System.out.print("\n File copied to destination");
        return true;
}

Performance: Very slow file copying to Windows network using JCIF, I'm trying to copy a file from my local machine to Shared folder in a windows server. This is the function which I used. public static void copyFileUsingJcifs(final​  after the latest windows update 1809 i am now facing very slow network file transfer speed to a nas, copying files from nas (nas1) is not a problem but moving/writing files into the nas (nas1) is very slow at around 0 kb/s. copying files to another nas (nas2) is also not a problem as shown from the screenshot below.

What I noticed is that jCIFS does "something" (afair jcifs.smb.SmbTransport.checkStatus(..)) for every chunk it reads - i.e. for each chunk that is read into the buffer. That means increasing your buffer size might really speed things up, although the real problem still exists, but only occurs 1 or 2 times having a lower impact on the overall time..

It helps a lot to set "jcifs.util.loglevel=3" and have a look what's really wrong..

In my case I had to set "jcifs.smb.client.dfs.disabled=false" in the end, as "jcifs.resolveOrder=DNS" didn't help..

JCIFS is slow, extremely slow · Issue #104 · AgNO3/jcifs-ng · GitHub, However it doesn't help in terms of performance, not a single bit. On the same WiFi network, using the same NAS and the same Android app, FTP file-copy goes to 45MB/s while jcifs(-ng) is limited to 4.5MB/s, that's a tenth of However from a Windows desktop I get those 45-50MB/s bandwidth as expected. You need to figure out what exactly causes the slow file transfer issue or change the way of Windows 10 file transfer on your PC or laptop. Very slow file transfer in Windows 10 can result from several factors, including network problems, external drives problems, or computer problems.

In case it helps others...I had a similar issue, but in the other direction (slow copying TO Windows using JCIFS). The issue was resolved by adding

   -Djcifs.resolveOrder=DNS

to the property list. (The default inclusion of BCAST -- to send a NetBIOS name query broadcast to 255.255.255.255 -- is what was causing the enormous delay.)

[jcifs] Re: Large File upload performance, Are there any planned improvements to JCIFS (wrt to speed) or is there any I tried copying large files (~ 75 MB) to remote machine using the JCIFS But the best timing was about 3 > > times > > slower. I found this was 2x faster than NT (using Windows Explorer) when copying > bushy directories of  I've been testing using the same ~2 GB file (database backup). If I run the copy from Server 2008 R2, I get consistent copy speeds of 100+ MB/s. The same copy on Server 2012 R2 gets stuck at 20-25 MB/s, bouncing up and down, and sometimes dropping to 0 b/s and pausing for some time.

I was having the same issue. Tried -Djcifs.resolveOrder=DNS with no luck. After reading a few comments with buffer size I decided to go to the extreme and really ramp it up. I know my transfer rate should be at least 50mb/s so I converted that to bytes and set it as my buffer and it worked as expected.

[jcifs] Slow File Copy from Windows to Linux using JCIFS 1.3.17, Windows to Linux using JCIFS. After upgrading from v 1.2.9 to 1.3.17, the > performance turned very slow. A copy of 1.3 MB file using JCIFS v  Recently I had to solve a problem of a very slow transfer of files between two computers on a LAN network using Ethernet cable. Both machines had Windows 7 x64 installed and the transfer speed was ridiculously slow at 10-15kb/s. Using Task Manager under Networking tab, Network Utilization was showing only around 0.25% for Local Area Connection.

Slow SMB files transfer speed, Introduces how to troubleshoot SMB files transfer performance issue. This is because file copy speeds are limited by storage speed. Run the following PowerShell command in Windows 8 and Windows For more information, see aving Office documents to a network server is slow when using EFS. Increase Local Area Network Speed in Windows 10 Solution. Speed up LAN Connection in Windows 7. LAN Connection is Slow Solved. Make My LAN Network Faster.

[JENKINS-10674] Publish over CIFS performance is slow, It takes (consistently) 7 minutes to copy a 12MiB file to the windows Can you try adding these to the system properties for whatever container you are using? plugin which is using the jcifs implementation it performs rather slow. http://​thread.gmane.org/gmane.network.samba.java/8878/focus=8884. File copy between PCs and a file server became excruciatingly slow, about 10Mbps over my 1Gbps connection. The PCs had recently been moved from one room, where they were connected through a series of 3 switches (one at the PC site, my main backbone switch, and a switch at the server site), to another room where they were only connected through

SMB transfer over wifi slow, I get speeds around 600-700 KB/s with pure file transfer for SMB on a Galaxy Nexus. Now I tried it with an high performance tablet and still only 700kb/s. I get transfer rates of about 2MB/s with jCIFS and Solid Explorer and 2,5MB/s with an native Maybe I have to set up a WebDAV server on my windows machine.

Copying the resources to and from windows network using Java ~ Salil, File copy using this approach is bit slower but suitable on the provides better performance than JCIFS but require the user running the java 

Comments
  • There could be lots of reasons, buffer over/under runs (ie the write taking longer the read, slowing the whole process down), network latency (unoptimised handling of packets) and API overhead. Try playing around with the byte buffer a little and see if that changes anything
  • @MadProgrammer I tried with both low buffer size and some big values. But there wasn't any better performance changes. I'm using jcifs-1.3.17.jar
  • 8 minutes for 25 megabytes is quite slow for a LAN. What is your environment?
  • @ThorbjørnRavnAndersen I tried to copy the file to a remote location. In LAN its working fine. I'm using Windows 7 on my machine. And the Server is running on Windows Server 2008.
  • Sounds like small buffer sizes (either your buffer or transfer buffers inside JCIF).
  • Did you change the buffer size on the Java client-side only (if you remember ...), inside the JCIFS lib ?
  • Unfortunately, I do not remember.