Here you can find the source of writeStringToFile(String path, String content)
public static void writeStringToFile(String path, String content) throws IOException
//package com.java2s; /*/*www .ja va 2 s . co m*/ * Sonar MSBuild Plugin, open source software quality management tool. * Author(s) : Jorge Costa @ jmecsoftware.com * * Sonar MSBuild Plugin is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * Sonar MSBuild Plugin is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void writeStringToFile(String path, String content) throws IOException { File file = new File(path); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(file)); writer.write(content); } finally { if (writer != null) writer.close(); } } }