Apache POI will quite happily let you read and edit the metadata of supported documents. For the older OLE2 formats (.doc, .xls etc), you'll want to use HPSF, likely via POIDocument. For the OOXML formats (.docx, .xlsx etc) use POIXMLDocument and POIXMLProperties
To modify the OLE2 properties, you can either follow the detailed instructions and code in the HPSF documentation, or on newer version of POI you can short cut quite a bit of that with HPSFPropertiesOnlyDocument, eg
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File("test.doc"));
HPSFPropertiesOnlyDocument doc = new HPSFPropertiesOnlyDocument(fs);
SummaryInformation si = doc.getSummaryInformation();
if (si == null) doc.createInformationProperties();
si.setAuthor("StackOverflow");
si.setTitle("Properties Demo!");
FileOutputStream out = new FileOutputStream("changed.doc");
doc.write(out);
out.close();