Write string.

@param obj  the obj
@param file the file
975668
public static void writeString(String obj, OutputStream file) {
    try {
      IOUtils.write(obj.getBytes("UTF-8"), file);
      file.close();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
953937
public void write(File file) throws Exception {
        try {
            FileOutputStream fos = new FileOutputStream(file);
            write(fos);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
77709
public <TYPE> void write(@NotNull final TYPE obj, @NotNull final File file, @NotNull final JAXBContext jaxbContext)
            throws MarshalObjectException {

        Contract.requireArgNotNull("obj", obj);
        Contract.requireArgNotNull("file", file);
        Contract.requireArgNotNull("jaxbContext", jaxbContext);

        try {
            final FileWriter fw = new FileWriter(file);
            try {
                write(obj, fw, jaxbContext);
            } finally {
                fw.close();
            }
        } catch (final IOException ex) {
            throw new MarshalObjectException("Unable to write XML to file: " + file, ex);
        }
    }
42907
public static void serialize(Object object, String file) throws Exception {
        if (object instanceof Serializable) {
            try (FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out =
                    new ObjectOutputStream(fileOut)) {
                out.writeObject(object);
            }
        } else {
            throw new Exception(object.getClass().getName() + " doesn't implements serializable interface");
        }
    }
827036
private void writeStringToFile(String str, File file) throws IOException {
        if (!file.exists() && file.isDirectory()) {
            return;
        }

        try (BufferedWriter bw = new BufferedWriter(WriterFactory.newWriter(file, this.encoding))) {
            bw.write(str);
        }
    }
58584
public static File writeObjectToFile(Object o, File file, boolean append) throws IOException {
    // file.createNewFile(); // cdm may 2005: does nothing needed
    ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(
        new GZIPOutputStream(new FileOutputStream(file, append))));
    oos.writeObject(o);
    oos.close();
    return file;
  }
1319722
public static void writeObjectToFile(File file, Object object) throws IOException {
    FileOutputStream fs = new FileOutputStream(file);
    ObjectOutputStream os = new ObjectOutputStream(fs);
    os.writeObject(object);
    os.close();
  }
209326
public static void print(final Object obj)
	{
		System.out.println(getInstance(obj.getClass()).serialise(obj));
	}
570351
public void writeToFile(File file, String fileContent) {
        if (!file.exists()) {
            try {
                FileWriter writer = new FileWriter(file);
                writer.write(fileContent);
                writer.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {

            }
        }
    }
1306600
private void writeObject(Writable obj) throws IOException {
    // For Text and BytesWritable, encode them directly, so that they end up
    // in C++ as the natural translations.
    if (obj instanceof Text) {
      Text t = (Text) obj;
      int len = t.getLength();
      WritableUtils.writeVInt(stream, len);
      stream.write(t.getBytes(), 0, len);
    } else if (obj instanceof BytesWritable) {
      BytesWritable b = (BytesWritable) obj;
      int len = b.getLength();
      WritableUtils.writeVInt(stream, len);
      stream.write(b.getBytes(), 0, len);
    } else {
      buffer.reset();
      obj.write(buffer);
      int length = buffer.getLength();
      WritableUtils.writeVInt(stream, length);
      stream.write(buffer.getData(), 0, length);
    }
  }
787661
public void write(Object from, File target) throws IOException {
    OutputStream outputStream = new FileOutputStream(target);
    try {
      write(from, outputStream);
    } finally {
      outputStream.close();
    }
  }
961633
public void stringToFile(String content, File file) throws IOException {
        stringToOutputStream(content, new FileOutputStream(file));
    }
560753
public void addOutputFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (f.isDirectory()) {
                throw new IllegalArgumentException("output file parameter points to a directory, must be a file");
            } else if (f.exists() && !f.canWrite()) {
                throw new IllegalArgumentException(
                        "output file parameter points to a file we have no write permissions");
            }

            setOutputFile(f);
        }
    }
626499
public static void doObjToFile(String file, Object[] objs) {
		ObjectOutputStream oos = null;
		try {
			FileOutputStream fos = new FileOutputStream(file);
			oos = new ObjectOutputStream(fos);
			for (int i = 0; i < objs.length; i++) {
				oos.writeObject(objs[i]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				oos.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
1316515
public final void writeTo(String fmt, File file) throws IOException {
        try (FileOutputStream out = new FileOutputStream(file)) {
            writeTo(fmt, out);
        }
    }
541812
public void writeXML(File file) throws IOException {
        OutputStream out = new FileOutputStream(file);
        if (file.getName().endsWith(".gz")) {
            out = new GZIPOutputStream(out);
        }
        writeXML(out);
    }
576437
@SuppressWarnings("unchecked")
  public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
    write(out, label, (O) object);
  }