Here you can find the source of saveStringToFile(File file, String content, String charset)
Parameter | Description |
---|---|
file | a parameter |
content | a parameter |
charset | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
UnsupportedEncodingException | an exception |
public static void saveStringToFile(File file, String content, String charset) throws IOException
//package com.java2s; import java.io.*; public class Main { /**/* w w w . j a v a2 s . c o m*/ * Saves specified content to the file with specified charset. * * @param file * @param content * @param charset * @throws IOException * @throws UnsupportedEncodingException */ public static void saveStringToFile(File file, String content, String charset) throws IOException { FileOutputStream out = new FileOutputStream(file); byte[] data = content.getBytes(charset); out.write(data); out.flush(); out.close(); } }