次のシナリオでどのように進めるか、誰でも私に説明できますか?
Java のログイン資格情報を使用して、ローカル マシンから Windows ファイル共有のファイル (docx、pptx など) のメタデータ (:tag、title など) を更新する必要があります。
注: 1.i Apache poi を使用して、ローカル ファイル システムにあるファイルのメタデータを更新しました。
2. Windows 共有のファイルにアクセスするには、jCIFS を使用し、smbFile オブジェクト参照を InputStream として POIFSFileSystem に渡しました。以下のようなエラーが発生します。
java.io.IOException: ヘッダー全体を読み取ることができません。0 バイトが読み取られました。予想される 512 バイト
これは私が試したコードです:
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();
}
ローカルマシンでファイルを更新しようとすると同じコードが機能しますが、ホストマシンで更新しようとすると機能しません。
これを行う他の方法はありますか?前もって感謝します .............