centos 下安装yum install samba um install samba samba-client samba-swat 有依赖关系的包samba-common、samba-winbind-clients、libsmbclient将自动安装上去。 配置参考如下:http://www.cnblogs.com/whiteyun/archive/2011/05/27/2059670.html不要把共享文件夹放在root下 放在home下好一点(我就是在这里浪费时间了) 曾参考的URL: http://blog.csdn.net/jastar/article/details/5639152 http://www.cnblogs.com/whiteyun/archive/2011/05/27/2059670.html http://blog.csdn.net/zdwzzu2006/article/details/4209877 http://www.samba.org/ http://jingyan.baidu.com/article/8cdccae9be9367315413cde9.html代码如下: import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.UnknownHostException; import jcifs.smb.SmbException; import jcifs.smb.SmbFile; import jcifs.smb.SmbFileInputStream; public class TestSamba { public static String readFromFile(SmbFile fileName,String encoding) throws IOException{ ByteArrayOutputStream baos = new ByteArrayOutputStream(); SmbFileInputStream fis=new SmbFileInputStream(fileName); byte[] cbuf=new byte[1024]; int len=0; while((len=fis.read(cbuf))!=-1){ baos.write(cbuf, 0, len); } fis.close(); baos.close(); String txt=baos.toString(encoding); return txt; } public static void main(String[] args) { try { // SmbFile file =new SmbFile("smb://root:123456@192.9.117.111/guoing/"); // // if(file.exists()){ // SmbFile[] files=file.listFiles(); // for (int i = 0; i < files.length; i++) { // System.out.println(files[i].toString()); // } // } // //String res=SambaUtil.readfile("192.9.117.111/guoing/a.txt","root","123456"); String path="smb://192.9.117.81/**/a.txt"; //path="smb://root:123456@192.9.117.111/guoing/dump"; SmbFile file =new SmbFile(path); String res=readFromFile(file,"GBK"); System.out.println(res); } catch (Exception e) { e.printStackTrace(); } } } 测试成功~