public VSphereOutputStream(
     VsphereConnHandler connHandler,
     ManagedObjectReference fileManager,
     ManagedObjectReference vm,
     NamePasswordAuthentication credentials,
     String fileName)
     throws FileNotFoundException, IOException {
   this(
       connHandler,
       fileManager,
       vm,
       credentials,
       File.createTempFile("tmpVixCopy", ".tmp"),
       fileName);
 }
 @Override
 public void close() throws IOException {
   if (connHandler == null) {
     return;
   }
   super.close();
   InputStream in = new FileInputStream(tmpFile);
   try {
     copyFileToRemote(fileName, in, this.tmpFile.length(), connHandler, fileManager);
   } finally {
     connHandler.releaseLock();
     connHandler = null;
     in.close();
     tmpFile.delete();
   }
 }