New version (requires VERSION privileges):
boolean keepLock = false;
String versionLabels = "";
IDfSysObject doc = (IDfSysObject) session.getObject(new DfId("0900000000000000"));
doc.checkout();
doc.setFile("C:\\temp\\temp.jpg"); // assuming you're using windows
doc.checkin(keepLock, versionLabels);
- keepLock - whether to keep the document checked out after checkin operation
- versionLabels - label(s) (in addition to the built-in ones which are configured elsewhere)
Same version (requires WRITE privileges):
IDfSysObject doc = (IDfSysObject) session.getObject(new DfId("0900000000000000"));
doc.fetch(null);
doc.setFile("C:\\temp\\temp.jpg"); // again, assuming the worst ;)
doc.save();
Note that fetch(null) is needed to make sure you have the most current version of the document at hand.
For both examples above the content file is replaced without any further magic. Be sure to rename the document as desired, and set the correct format if necessary, e.g.:
doc.setObjectName("new_name");
doc.setContentType("new_format");