Here you can find the source of writeFile(final File outputFile, final String data, final String encoding)
Parameter | Description |
---|---|
outputFile | File to save to (overwriting any existing content) |
data | String data to store |
Parameter | Description |
---|---|
IOException | if the usual bad things happen |
UnsupportedEncodingException | if the given encodingis not supported. |
@Deprecated public static void writeFile(final File outputFile, final String data, final String encoding) throws IOException
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { /**//from www . j a v a2s. c o m * Writes the given String data to the given output file, encoded using * the given encoding. * * @param outputFile File to save to (overwriting any existing content) * @param data String data to store * * @throws IOException if the usual bad things happen * @throws UnsupportedEncodingException if the given encoding * is not supported. */ @Deprecated public static void writeFile(final File outputFile, final String data, final String encoding) throws IOException { final FileOutputStream outStream = new FileOutputStream(outputFile); OutputStreamWriter writer = null; try { writer = new OutputStreamWriter(outStream, encoding); writer.write(data); } finally { if (writer != null) { writer.close(); } else { outStream.close(); } } } }