title: How to upload a document using CMIS?
body: <p>I am learning CMIS and have come across code similar to following which creates a document using CMIS. I want to use createDocument method of CMIS to upload a file stored in a folder in my local machine. How can I achieve that?</p>
  
  <pre><code>Folder parent = ....
  
  String name = "myNewDocument.txt";
  
  // properties 
  // (minimal set: name and object type id)
  Map&lt;String, Object&gt; properties = new HashMap&lt;String, Object&gt;();
  properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
  properties.put(PropertyIds.NAME, name);
  
  // content
  byte[] content = "Hello World!".getBytes();
  InputStream stream = new ByteArrayInputStream(content);
  ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(content.length), "text/plain", stream);
  
  // create a major version
  Document newDoc = parent.createDocument(properties, contentStream, VersioningState.MAJOR);
  </code></pre>