package com.sgcc.jysf.file;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
public class MainDemo {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
try {
SmbFile smbFile = new SmbFile("smb://用户名:密码@远程IP/共享文件/共享文件中需要读取的文本");
int length = smbFile.getContentLength();
byte buffer[] = new byte[length];
SmbFileInputStream in = new SmbFileInputStream(smbFile);
while ((in.read(buffer)) != -1) {
System.out.write(buffer);
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
public class MainDemo {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
try {
SmbFile smbFile = new SmbFile("smb://用户名:密码@远程IP/共享文件/共享文件中需要读取的文本");
int length = smbFile.getContentLength();
byte buffer[] = new byte[length];
SmbFileInputStream in = new SmbFileInputStream(smbFile);
while ((in.read(buffer)) != -1) {
System.out.write(buffer);
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}