Writes Java object to a file.

@param object   the object
@param fileName the file where the object will be written
@throws DISIException DISIException
490220
public static void writeObject(Object object, String fileName) throws DISIException {
        log.info("Writing " + fileName);
        try {
            FileOutputStream fos = new FileOutputStream(fileName);
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(object);
            oos.close();
            fos.close();
        } catch (IOException e) {
            final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
            log.error(errMessage, e);
            throw new DISIException(errMessage, e);
        }
    }
14329
public static File writeObjectToFile(final Object o, final String fileName)
      throws IOException {
    final File outFile = new File(fileName);
    OutputStream outputStream = new FileOutputStream(outFile);
    if (fileName.endsWith(".gz")) {
      outputStream = new GZIPOutputStream(outputStream);
    }
    outputStream = new BufferedOutputStream(outputStream);
    final ObjectOutputStream oos = new ObjectOutputStream(outputStream);
    oos.writeObject(o);
    oos.close();
    return outFile;
  }
475798
private void writeObject(java.io.ObjectOutputStream s)
        throws IOException {
        s.writeObject(thisX500Name.getEncodedInternal());
    }
735730
public static function writeToJsonFile(SpecObjectInterface $object, string $fileName): void
    {
        file_put_contents($fileName, static::writeToJson($object));
    }
1172721
public static void writeObject(final String serverName, final int port,
		final Object objectToSend) throws IOException
	{
		final InetAddress inetAddress = InetAddress.getByName(serverName);
		writeObject(inetAddress, port, objectToSend);
	}
648037
public void writeObject(Object obj, AbstractHessianOutput out) 
        throws IOException {
    	
        if (out.addRef(obj)) {
            return;
        }
	    
        Class< ? > cl = obj.getClass();
	    
        try {
            if (writeReplace != null) {
                Object repl = writeReplace.invoke(obj, new Object[0]);

                out.removeRef(obj);

                out.writeObject(repl);

                out.replaceRef(repl, obj);

                return;
            }
        } catch (Exception e) {
            log.log(Level.FINE, e.toString(), e);
        }

        int ref = out.writeObjectBegin(cl.getName());

        if (ref < -1) {
	    // Hessian 1.1 uses a map
	      
            for (int i = 0; i < localMethods.length; i++) {
                Object value = null;

                try {
                    value = localMethods[i].invoke(obj, (Object []) null);
                } catch (Exception e) {
                    log.log(Level.FINE, e.toString(), e);
                }
		
                if (!LazyUtil.isPropertyInitialized(value)) {
                    continue;
                }
		
                out.writeString(localNames[i]);
		
                out.writeObject(value);
            }
	      
            out.writeMapEnd();
        } else {
            if (ref == -1) {
                out.writeInt(localNames.length);
		
                for (int i = 0; i < localNames.length; i++) {
                    out.writeString(localNames[i]);
                }
                out.writeObjectBegin(cl.getName());
            }

            for (int i = 0; i < localMethods.length; i++) {
                Object value = null;

                try {
                    value = localMethods[i].invoke(obj, (Object []) null);
                } catch (Exception e) {
                    log.log(Level.FINER, e.toString(), e);
                }
		
                if (!LazyUtil.isPropertyInitialized(value)) {
                    continue;
                }
		
                out.writeObject(value);
            }
        }
    }
227860
public static File writeObjectToFile(Object o, String filename)
  throws IOException {
    return writeObjectToFile(o, new File(filename));
  }
151992
public static void writeClass(String fileName, byte[] bytes) throws IOException {
      try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
         out.write(bytes);
      }
   }
637984
public void writeToFile() throws IOException {
        FileOutputStream fos = new FileOutputStream(new File(this.hashFunctionFile));
        store(fos);
        fos.close();
    }
1356518
public void writeToFileWithoutFactors(String filename) throws IOException {
        FileOutputStream fos = new FileOutputStream(filename);
        writeToStreamWithoutFactors(fos);
        fos.close();
    }
915359
public void send(Object object) {
        if (object instanceof File) {
            file((File) object);
        } else {
            send(object, getContentType());
        }
    }
633171
private void writeObject(final ObjectOutputStream out)
		throws IOException
	{
		out.defaultWriteObject();

		out.writeInt(_length);
		out.writeDouble(_p);
		out.writeInt(_genes.length);
		out.write(_genes);
	}
391887
private synchronized void writeObject(final ObjectOutputStream s) throws IOException {
        if ( null != field ) {
            this.object = field.getDeclaringClass();
            this.varName = field.getName();
            this.field = null;
        }
        s.defaultWriteObject();
    }
980120
@Override
    public void write(final File filename) throws DITAOTException {
        assert filename.isAbsolute();
        setCurrentFile(filename.toURI());
        super.write(filename);
    }
377085
public static void serialize(File file, SerializableObject object) throws IOException {
		AtomicFile atomicFile = new AtomicFile(file);
		FileOutputStream stream = null;
		try {
			stream = atomicFile.startWrite();
			DataOutputStream out = new DataOutputStream(stream);
			object.writeExternal(out);
			atomicFile.finishWrite(stream); // serialization was successful
		} catch (Exception e) {
			atomicFile.failWrite(stream); // serialization failed
			throw new IOException(e); // throw exception up the chain
		}
	}
743523
function send(object) {
  if (typeof object === 'object') {
    return write(this.filepath, JSON.stringify(object, null, '  '));
  } else {
    return write(this.filepath, object.toString());
  }
}
176509
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    save(baos);

    byte[] data = baos.toByteArray();

    out.writeInt(data.length);
    out.write(data);
  }