使用凭据将I / O文件写入共享网络驱动器 [英] Write I/O file to shared network drive using credentials
本文介绍了使用凭据将I / O文件写入共享网络驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
FileOutputStream fos;
DataOutputStream dos;
尝试{
File file = new File(path +/+ fileName +.txt);
fos = new FileOutputStream(file);
dos = new DataOutputStream(fos);
dos.writeChars(stringContent);
dos.close();
fos.close();
catch(IOException eio){
}
你
解决方案
没有。使用java CIFS客户端库。你可以通过java连接远程windows机器。例如 -
String user =user:password;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user);
String path =smb://my_machine_name/D/MyDev/test.txt;
SmbFile sFile = new SmbFile(path,auth);
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
sfos.write(Test.getBytes());
sfos.close();
谢谢
I want to drop a .txt file on a shared network drive. The path is a map on a networkdrive which requires credentials (login and password). Can i pass these parameters using FileOutputStream?
FileOutputStream fos;
DataOutputStream dos;
try {
File file= new File(path + "/" + fileName + ".txt");
fos = new FileOutputStream(file);
dos=new DataOutputStream(fos);
dos.writeChars(stringContent);
dos.close();
fos.close();
}
catch(IOException eio){
}
Thank you
解决方案
No. Use java CIFS Client library. you can connect remote windows machine through java. example -
String user = "user:password";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user);
String path = "smb://my_machine_name/D/MyDev/test.txt";
SmbFile sFile = new SmbFile(path, auth);
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
sfos.write("Test".getBytes());
sfos.close();
Thanks
这篇关于使用凭据将I / O文件写入共享网络驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文