Here you can find the source of writeStringToFile(String content, File outputfile)
Parameter | Description |
---|---|
content | The string to write out |
outputfile | The file to which the string will be written |
public static void writeStringToFile(String content, File outputfile)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { /**/*from w ww .j a v a 2 s.c o m*/ * Write a string to a file * @param content The string to write out * @param outputfile The file to which the string will be written */ public static void writeStringToFile(String content, File outputfile) { if (content != null && !content.equals("") && outputfile != null) { try { PrintWriter pwriter = new PrintWriter(new FileWriter( outputfile)); pwriter.print(content); pwriter.close(); } catch (IOException e) { e.printStackTrace(); } } } }