Skip to content

Instantly share code, notes, and snippets.

@idletekz
Created January 16, 2018 20:37
Show Gist options
  • Save idletekz/0b61db6899cd1cd42749d1c6bf47ca01 to your computer and use it in GitHub Desktop.
Save idletekz/0b61db6899cd1cd42749d1c6bf47ca01 to your computer and use it in GitHub Desktop.
https://stackoverflow.com/questions/17831777/write-to-a-windows-network-share-from-unix
try {
String filePath = "myserver/dir";
String fileName = "myFile.txt";
String user = "username";
String password = "password";
// URL: smb://user:passwd@host/share/filname
SmbFileOutputStream out = new SmbFileOutputStream("smb://" + user + ":" + password + "@" + filePath
+ File.separator + fileName);
out.write("test".getBytes());
out.close();
} catch (Exception e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment