如何使用java中的登录凭据从本地计算机更新windows fileshare中的文件?
有谁能向我解释一下,在下面的场景中如何进行 我需要使用java中的登录凭据从本地计算机更新windows fileshare中的metadatalike:tag、filelike:docx、pptx等文件的标题 注: 1.我已经使用Apache poi更新了本地文件系统中的文件元数据 2.为了访问windows共享中的文件,我使用了jCIFS,并将smbFile对象引用作为InputStream传递给POIFSF文件系统,我得到一个错误,如下所示 java.io.IOException:无法读取整个标头;读取0字节;应为512字节 这是我尝试过的代码:如何使用java中的登录凭据从本地计算机更新windows fileshare中的文件?,java,metadata,jcifs,Java,Metadata,Jcifs,有谁能向我解释一下,在下面的场景中如何进行 我需要使用java中的登录凭据从本地计算机更新windows fileshare中的metadatalike:tag、filelike:docx、pptx等文件的标题 注: 1.我已经使用Apache poi更新了本地文件系统中的文件元数据 2.为了访问windows共享中的文件,我使用了jCIFS,并将smbFile对象引用作为InputStream传递给POIFSF文件系统,我得到一个错误,如下所示 java.io.IOException:无法读取
public static void main(String[] args)
{
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain","username","passw0rd$");
SmbFile sFile = new SmbFile("smb://host/SharedFiles/adoc.doc", auth);
sFile.connect();
/* Open the POI filesystem. */
InputStream is = new SmbFileInputStream(sFile);
POIFSFileSystem poifs = new POIFSFileSystem(is);
// is.close();
/* Read the summary information. */
DirectoryEntry dir = poifs.getRoot();
SummaryInformation si;
try
{
DocumentEntry siEntry = (DocumentEntry)
dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
DocumentInputStream dis = new DocumentInputStream(siEntry);
PropertySet ps = new PropertySet(dis);
dis.close();
si = new SummaryInformation(ps);
}catch (FileNotFoundException ex)
{
/* There is no summary information yet. We have to create a new
* one. */
si = PropertySetFactory.newSummaryInformation();
}
si.setKeywords("mykeyword");
// some code ..................
/* Write the summary information and the document summary information
* to the POI filesystem. */
si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
FileOutputStream out = new FileOutputStream(poiFilesystem);
poifs.writeFilesystem(out);
out.close();
}
如果我尝试在本地计算机中更新文件,同样的代码也可以工作,但如果我尝试在主机中更新文件,则该代码不起作用
请告诉我还有别的办法吗?
提前感谢………使用Jcifs写入文件共享。请尝试以下代码 样本:
SmbFile destFile = new SmbFile("smb://host/SharedFiles/adoc.doc", auth);
SmbFileOutputStream sfos = new SmbFileOutputStream(destFile);
poifs.writeFilesystem(sfos);
sfos.close();