需要引入的jar包jcifs-1.3.18.jar
public static void main(String[] args) throws Exception {
String user = "共享windows的用户名";
String pass = "共享windows的密码";
我的共享目录为//100.100.11.19//myshare//file//test.txt
String path = "smb://100.100.11.19//myshare//file//test.txt";
String res=getShareFileContent(user,pass,path);
System.out.println(res);
}
/**
*
* @param username 远程windows用户名
* @param password 远程windows密码
* @param sharePath 共享文件路径
* @return 文件内存
*/
public static String getShareFileContent(String username, String password, String sharePath) {
StringBuilder stringBuilder=new StringBuilder();
SmbFile smbFile = null;
SmbFileInputStream smbfos = null;
InputStreamReader inputStreamReader = null;
B