あなたの質問の時点では、悲しいことに、それを行うための非常にメモリの少ない方法はありませんでした。良いニュースは、2014 年 4 月 28 日現在、それが可能であるということです! (このコードは、リリース時には 3.11 に含まれているはずですが、現時点では新しすぎます)
NPOIFS がインプレース書き込みを含む書き込みをサポートするようになったので、次のようにします。
// Open the file, and grab the entries for the summary streams
NPOIFSFileSystem poifs = new NPOIFSFileSystem(file, false);
DocumentNode sinfDoc =
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
DocumentNode dinfDoc =
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
// Open and parse the metadata
SummaryInformation sinf = (SummaryInformation)PropertySetFactory.create(
new NDocumentInputStream(sinfDoc));
DocumentSummaryInformation dinf = (DocumentSummaryInformation)PropertySetFactory.create(
new NDocumentInputStream(dinfDoc));
// Make some metadata changes
sinf.setAuthor("Changed Author");
sinf.setTitle("Le titre \u00e9tait chang\u00e9");
dinf.setManager("Changed Manager");
// Update the metadata streams in the file
sinf.write(new NDocumentOutputStream(sinfDoc));
dinf.write(new NDocumentOutputStream(dinfDoc));
// Write out our changes
fs.writeFilesystem();
fs.close();
ファイルのサイズの 20% 未満のメモリで、これらすべてを実行できるはずです。これは、大きなファイルの場合よりも少ない可能性があります。
(これについて詳しく知りたい場合は、ModifyDocumentSummaryInformation の例とHPSF TestWrite 単体テストを参照してください)