java使用jcifs读取文件的最简单方法
我正在尝试使用外部jcifs library从网络共享读取文件。我能找到的大多数用于读取文件的示例代码都非常复杂,可能是不必要的。我找到了一种将写入文件的简单方法,如下所示。有没有使用类似语法读取文件的方法
SmbFile file= null;
try {
String url = "smb://"+serverAddress+"/"+sharename+"/TEST.txt";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, username, password);
file = new SmbFile(url, auth);
SmbFileOutputStream out= new SmbFileOutputStream(file);
out.write("test string".getBytes());
out.flush();
out.close();
} catch(Exception e) {
JOptionPane.showMessageDialog(null, "ERROR: "+e);
}
# 1 楼答案
# 2 楼答案
我可以使用以下内容阅读一些pdf文件:
# 3 楼答案
或者更好,假设您正在使用Java SDK中的
BufferedReader
处理文本文件:写下: