Here you can find the source of writeStringToFile(CharSequence contents, String filename)
Parameter | Description |
---|---|
contents | a parameter |
filename | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeStringToFile(CharSequence contents, String filename) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; import java.io.PrintStream; public class Main { /**// w ww .j av a2s . c o m * writes string contents to file file * * @param contents * @param file * * @throws IOException */ public static void writeStringToFile(CharSequence contents, File file) throws IOException { PrintStream ps = null; try { ps = new PrintStream(file); ps.print(contents); ps.close(); } finally { if (ps != null) //try { ps.close(); } catch ( IOException e ) {} ps.close(); } } /** * writes string contents to file file * * @param contents * @param filename * * @throws IOException */ public static void writeStringToFile(CharSequence contents, String filename) throws IOException { writeStringToFile(contents, new File(filename)); } }