Java Text File Write writeStringToFile(String path, String content)

Here you can find the source of writeStringToFile(String path, String content)

Description

write String To File

License

Open Source License

Declaration

public static void writeStringToFile(String path, String content)
            throws IOException 

Method Source Code

//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();
        }
    }
}

Related

  1. writeStringToFile(String fullPath, String content)
  2. writeStringToFile(String jsonStr, File file)
  3. writeStringToFile(String macroContent, File file)
  4. writeStringToFile(String modifiedLine, String filePath)
  5. writeStringToFile(String path, String content)
  6. writeStringToFile(String path, String content)
  7. writeStringToFile(String path, String contents)
  8. writeStringToFile(String s, File f)
  9. writeStringToFile(String s, File f)