Here you can find the source of writeString(File file, String data)
Parameter | Description |
---|---|
data | the data to write in the file |
public static void writeString(File file, String data) throws IOException
//package com.java2s; import java.io.*; public class Main { /**//from w w w . j a v a 2s . c o m * * @param dir directory to put the file in * @param name name of new file * @param data the data to write in the file */ public static void writeString(File dir, String name, String data) throws IOException { writeString(new File(dir, name), data); } /** * * @param data the data to write in the file */ public static void writeString(File file, String data) throws IOException { PrintWriter out = null; try { out = new PrintWriter(new FileOutputStream(file)); out.print(data); } finally { // try { if (out != null) out.close(); // } catch (IOException e) {} } } }