Here you can find the source of writeStringToFile(String filename, String text)
public static void writeStringToFile(String filename, String text)
//package com.java2s; //License from project: Open Source License import java.io.FileOutputStream; import java.io.PrintStream; public class Main { public static void writeStringToFile(String filename, String text) { FileOutputStream stream = null; PrintStream out = null;// w w w.ja va 2 s. c om try { stream = new FileOutputStream(filename); out = new PrintStream(stream); out.print(text); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (stream != null) stream.close(); if (out != null) out.close(); } catch (Exception ex) { ex.printStackTrace(); } } } }