Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void save2FileQuiet(String content, File file) { try { save2File(content, file); } catch (IOException e) { // nothing to do } } public static void save2FileQuiet(String content, String charset, File file) { try { save2File(content, charset, file); } catch (IOException e) { // nothing to do } } public static void save2FileQuiet(byte[] content, File file) { try { save2File(content, file); } catch (IOException e) { // nothing to do } } public static void save2File(String content, File file) throws IOException { save2File(content, "UTF-8", file); } public static void save2File(String content, String charset, File file) throws IOException { save2File(content.getBytes(charset), file); } public static void save2File(byte[] content, File file) throws IOException { FileOutputStream outStream = new FileOutputStream(file); outStream.write(content); outStream.flush(); outStream.close(); } }