// take a copy of the existing datastream versions
Date[] versions = w.getDatastreamVersions(dsID);
Map<Date, Datastream> copyDS = new HashMap<Date, Datastream>();
for (Date version: versions) {
Datastream d = w.GetDatastream(dsID, version);
copyDS.put(version, d.copy());
}
// purge the existing datastream (all versions)
w.removeDatastream(dsID, null, null);