Write the text to the File without writing a BOM,
using the specified encoding.

@param file    a File
@param text    the text to write to the File
@param charset the charset used
@throws IOException if an IOException occurs.
@since 1.0
160121
public static void write(File file, String text, String charset) throws IOException {
        write(file, text, charset, false);
    }
366833
public static void write(String string, File file) throws IOException {
        try (Writer w = new OutputStreamWriter(new FileOutputStream(file), ENCODING_UTF_8)) {
            w.write(string);
        }
    }
849418
public static void writeFile( String text, File file ) throws IOException {
        try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {

            bw.write(text);
        }
    }
1090178
@Override
	public void writeString(String str) throws IOException {
		byte[] bytes = Utf8.getBytesFor(str);
		writeBytes(bytes, 0, bytes.length);
	}
978893
public static void write(String path, String str) throws IOException {
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
				path), "utf8"));
		out.append(str);
		out.close();		
	}
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);
        }
    }
636665
public static void writeContent(CharSequence content, File file, String encoding) {
        OutputStream os = null;
        try {
            os = new FileOutputStream(file);
            PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(os, encoding));
            printWriter.println(content);
            printWriter.flush();
            os.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (os != null) os.close();
            } catch (Exception e) {
                //
            }
        }
    }
238846
public void writeTo(File file) throws IOException {
        FileChannel channel = new FileOutputStream(file).getChannel();
        try {
            writeTo(channel);
        } finally {
            channel.close();
        }
    }
1337306
public static String readString(File file, Charset charset) throws IORuntimeException {
		return FileReader.create(file, charset).readString();
	}
1276320
public static void writeTextFile(String text,File file) throws IOException
    {
        Writer writer=null;
        try
        {
            //create writer to file (with default encoding)
            OutputStream outputStream=new FileOutputStream(file);
            writer=IOHelper.createWriter(outputStream,null);
            
            //write to file
            writer.write(text);
        }
        finally
        {
            //close writer
            IOHelper.closeResource(writer);
        }
    }
397518
private void writeTheLines(final BufferedOutputStream stream,
            final String charset)
            throws IOException {
        for (final GedWriterLine line : visitor.getLines()) {
            if (line.getLine().isEmpty()) {
                continue;
            }
            final String string = line.getLine();
            stream.write(string.getBytes(charset));
            stream.write('\n');
        }
    }
54003
public static void saveFile(final File file, final String contents, final String encoding) throws IOException {
        saveFile(file, contents.getBytes(encoding));
    }
866499
public static String readFromFile(final File file, final Charset encoding) throws IOException
	{
		return inputStream2String(StreamExtensions.getInputStream(file), encoding);
	}
183980
public static void write(final CharSequence data, final File file) throws IOException {
		Validate.notNull(file);
		Validate.notNull(data);

		try (BufferedWriter writer = Files.newBufferedWriter(file.toPath(), Charsets.UTF_8)) {
			writer.append(data);
		}
	}
249413
public static void encode(File file) throws IOException {
        if (!file.exists()) {
            System.exit(0);
        }

        else {
            byte[] decoded = readBytes(file);
            char[] encoded = encode(decoded);
            writeChars(file, encoded);
        }
        file = null;
    }
1225579
public static void append(File file, Object text) throws IOException {
        Writer writer = null;
        try {
            writer = new FileWriter(file, true);
            InvokerHelper.write(writer, text);
            writer.flush();

            Writer temp = writer;
            writer = null;
            temp.close();
        } finally {
            closeWithWarning(writer);
        }
    }
155479
public static void write(File file, String text, boolean append) throws IOException {
        FileWriter writer = new FileWriter(file, append);
        try {
            writer.write(text);
        } finally {
            writer.close();
        }
    }