Here you can find the source of writeStringToFile(String filename, String content)
public static void writeStringToFile(String filename, String content) throws FileNotFoundException
//package com.java2s; /*/*from w ww.j a va 2s.com*/ * Copyright (c) Ludger Solbach. All rights reserved. * The use and distribution terms for this software are covered by the * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) * which can be found in the file license.txt at the root of this distribution. * By using this software in any fashion, you are agreeing to be bound by * the terms of this license. * You must not remove this notice, or any other, from this software. */ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; public class Main { public static void writeStringToFile(String filename, String content) throws FileNotFoundException { File file = new File(filename); PrintWriter pw = new PrintWriter(new FileOutputStream(file)); pw.print(content); pw.close(); } public static void writeStringToFile(File file, String content) throws FileNotFoundException { PrintWriter pw = new PrintWriter(new FileOutputStream(file)); pw.print(content); pw.close(); } }