
您正在使它比应有的难度更大。请按照以下步骤 *** 作,并确保您正在创建的共享文件夹对此正在使用的用户具有写权限。
- 下载jar文件http://jcifs.samba.org/(只有一个jar文件)
- 复制并粘贴以下代码以及您的用户名,密码和共享文件夹信息,这就是您所需要的
我在Linux上运行此程序,想写入Windows框,因此如果您不知道如何在Windows上创建共享文件夹,请创建一个共享文件夹并将共享文件夹名称放在以下变量中…使用google一如既往
String user = "your_user_name"; String pass ="your_pass_word"; String sharedFolder="shared"; String path="smb://ip_address/"+sharedFolder+"/test.txt"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass); SmbFile smbFile = new SmbFile(path,auth); SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile); smbfos.write("testing....and writing to a file".getBytes()); System.out.println("completed ...nice !");欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)