首先添加jar
jcifs
jcifs
1.3.17
com.jcraft
jsch
0.1.54
第一个肯定是要的,第二个最好也配置下。
下面来看代码,和一些方法示例
conStr = "smb://"+account+":"+password+"@"+remoteHostIp+"/"+shareDocName+"/"+remoteFileName;
public InputStream getFile(String path) throws IOException {
SmbFile smbFile = new SmbFile(fileRoot+path);
return smbFile.getInputStream();
}
public static void smbGet1(String remoteUrl) throws IOException {
SmbFile smbFile = new SmbFile(remoteUrl);
int length = smbFile.getContentLength(); // 得到文件的大小
byte buffer[] = new byte [length];
SmbFileInputStream in = new SmbFileInputStream(smbFile);
// 建立smb文件输入流
while ((in.read(buffer)) != - 1 ) {
Syst