Thursday, October 03, 2013

Write Text file to network drive


First you have to download CIFS Client library from http://jcifs.samba.org/

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);
    sfos.write("Test".getBytes());

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

No comments:

State Machine implementation for Spring Boot Project

Well I do not write a lot about it. You have plenty of resources to read about it. The behavior of state machines can be observed in many d...