code: public void write(String filename) throws Exception {
      data = new TiffOutputStream(input);
      data.setByteOrder(byteOrder);
      try {
        data.create(filename);
        writeHeader();
        writeIfds();
        data.close();
      } catch (Exception ex) {
        ex.printStackTrace();
        if (data != null) {
          data.close();
        }
        throw ex;
      }
    }
docs: Write.
  
  @param filename the filename
  @throws Exception the exception