Thursday, October 03, 2013

Write Text file to network drive

First you have to download CIFS Client library from

if you use domain then you have to use user variable like below,
    String user = "domain;user:password";

else use below code,
    String user = "user:password";

rest of the code should be like below,
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user);
    String path = "smb://server/D/MyLocation/data.txt";
    SmbFile sFile = new SmbFile(path, auth);
    SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);

There you go, data.txt should be there in your locatoin :-)