Java tutorial
//package com.java2s; //License from project: GNU General Public License import java.io.File; import java.io.FileOutputStream; public class Main { public static void writeToFile(String fileName, String content) { try { writeToFile(fileName, content.getBytes("UTF-8")); } catch (Exception e) { } } public static void writeToFile(String fileName, byte[] content) { File f = new File(fileName); if (!f.exists()) { try { f.createNewFile(); } catch (Exception e) { } } try { FileOutputStream opt = new FileOutputStream(f, false); opt.write(content, 0, content.length); opt.close(); } catch (Exception e) { } } }