Here you can find the source of saveUnicodeStringToFile(final String string, final File file)
Parameter | Description |
---|---|
string | The Java string to write |
file | the file to write to |
Parameter | Description |
---|---|
IOException | For any error |
public static void saveUnicodeStringToFile(final String string, final File file) throws IOException
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { /**//w w w .java 2 s .c om * Save unicode string to file. * * @param string The Java string to write * @param file the file to write to * @throws IOException For any error */ public static void saveUnicodeStringToFile(final String string, final File file) throws IOException { final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8")); bw.write(string); bw.flush(); bw.close(); } }