Here you can find the source of writeStringToFile(String sdat, File f)
public static boolean writeStringToFile(String sdat, File f)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.zip.GZIPOutputStream; public class Main { public static boolean writeStringToFile(String sdat, File f) { String fnm = f.getName(); boolean ok = false; if (f != null) { boolean dogz = (fnm.endsWith(".gz")); try { OutputStream fos = new FileOutputStream(f); if (dogz) { fos = new GZIPOutputStream(fos); }//from www. j a v a 2s . c o m OutputStreamWriter osw = new OutputStreamWriter(fos); osw.write(sdat, 0, sdat.length()); osw.close(); ok = true; } catch (IOException ex) { throw new RuntimeException("File write error, when writing " + fnm); } } return ok; } }