如何使用JCIF / SMB从服务器打开本地计算机上的文件

时间:2015-08-20 13:40:52

标签: java smb jcifs

如何在本地计算机sharedrive上打开doc或docx文件,但是我在samba库中找不到合适的方法来在本地计算机上打开该文件。有什么想法吗?

import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
import jcifs.smb.SmbFileOutputStream;
import jcifs.smb.FileUtilityService;
import org.apache.commons.vfs2.operations.FileOperation;


String user = "some_username";
String pass = "some_password";

db.log("Test log");

String filename = "testdoc.docx";
String path = "smb://my_path";

db.log("Path " + path);
try {
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(path,     user, pass);
    //FileOperation.openFile(path);
    db.log("Password Authentication Success");
    SmbFile smbFile = new SmbFile(path + filename, auth);
  db.log("SMB File is set up");
  //FileOperation.openFile(smbfile);
    //SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile);
    db.log("Setup the File Output ");

} catch (Exception e) {
    db.log("The error is: " + e.getMessage());
}

0 个答案:

没有答案