Here you can find the source of writeLineTextFile(File file, String data)
public static void writeLineTextFile(File file, String data)
//package com.java2s; import java.io.File; import java.io.PrintWriter; public class Main { public static void writeLineTextFile(File file, String data) { PrintWriter pw = null;//from w ww . ja va 2 s . c om try { pw = new PrintWriter(file); pw.print(data); pw.flush(); } catch (Exception e) { e.printStackTrace(); try { if (pw != null) { pw.close(); } } catch (Exception ex) { ex.printStackTrace(); } } finally { try { if (pw != null) { pw.close(); } } catch (Exception ex) { ex.printStackTrace(); } } } public static void writeLineTextFile(File file, String[] dataArray) { PrintWriter pw = null; try { pw = new PrintWriter(file); for (String data : dataArray) { pw.println(data); } pw.flush(); } catch (Exception e) { e.printStackTrace(); try { if (pw != null) { pw.close(); } } catch (Exception ex) { ex.printStackTrace(); } } finally { try { if (pw != null) { pw.close(); } } catch (Exception ex) { ex.printStackTrace(); } } } }