Here you can find the source of writeFile(String fileName, String fileData)
Parameter | Description |
---|---|
fileName | a parameter |
fileData | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeFile(String fileName, String fileData) throws IOException
//package com.java2s; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; public class Main { /**//from w ww .j a v a 2 s . com * Method writeFile. Writes string data to a file overwriting existing data. * * @param fileName * @param fileData * @throws IOException */ public static void writeFile(String fileName, String fileData) throws IOException { writeFile(fileName, fileData, false); } /** * Method writeFile. Writes string data to a file overwriting or appending to existing data based on the appendFlag. * * @param fileName * @param fileData * @param appendFlag * @throws IOException */ public static void writeFile(String fileName, String fileData, boolean appendFlag) throws IOException { Writer fileWriter = new FileWriter(fileName, appendFlag); fileWriter.write(fileData); fileWriter.close(); fileWriter = null; } }