Writer operations - script to Java migration

For the Writer operations, not all of the script operations from the Script API are implemented in the Java™ API. Alternative Java code is provided for those script operations that are not implemented in the Java API.

The following writer methods can be achieved by using a mix of java.io.* for file system and docstore APIs for writing to the docstore.
Table 1. Script operations and alternative Java code for the Writer operations
Script operation Alternative Java code
Close DocstoreManager.createDocument(); Document.setContent(String); Document.setContent(InputStream);
createOtherOut new PrintWriter(String fileName, String csn);
print PrintWriter.print();
println PrintWriter.println();
save DocstoreManager.createDocument(); Document.setContent(String); Document.setContent(InputStream);
setOutputAttribute Document.setProperty(Property, String); Document.setProperty(String, String);
setOutputName DocstoreManager.createDocument();
write PrintWriter.write();
writeBinaryFile Document.copyTo(String documentPath);
writeDoc String content = Document.getContent(); Writer.write(content);
writeFile
Document.writeContentToOutputStream(OutputStream);
new PrintWriter(OutputStream);
writeFileUsingReader char[] buffer = new char[1024]; int length = -1; while ((length = reader.read(buffer)) != -1) writer.write((char[])buffer, 0, length); reader.close();
writeln PrintWriter.writeln();
setOutputAttribute Document.setProperty(Property, String)
setOutputAttribute Document.setProperty(String, String)
setOutputAttribute PIMWriter.setProperty(String propertyName,String propertyValue)
setOutputName DocstoreManager.createDocument();
setOutputName PIMWriter.setName(String name)