Here you can find the source of writeString(String fileName, String str)
Parameter | Description |
---|---|
fileName | the file to write into |
str | the string to be written |
Parameter | Description |
---|---|
IOException | if an I/O error occurs |
public static void writeString(String fileName, String str) throws IOException
//package com.java2s; import java.io.*; public class Main { /**/*from ww w . j a va 2 s .c o m*/ * This writes a string into a given file. It opens the file, rewrites everything in it and * closes it afterwards. * * @param fileName the file to write into * @param str the string to be written * @throws IOException if an I/O error occurs */ public static void writeString(String fileName, String str) throws IOException { FileOutputStream os = new FileOutputStream(fileName); os.write(str.getBytes()); os.close(); } }