Here you can find the source of writeStringToFile(File file, String text)
Parameter | Description |
---|---|
file | text file |
text | text |
Parameter | Description |
---|---|
FileNotFoundException | If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file |
public static void writeStringToFile(File file, String text) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/*from ww w .j a va2s. c o m*/ * Writes a string into a file. * * @param file text file * @param text text * @throws FileNotFoundException If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file */ public static void writeStringToFile(File file, String text) throws FileNotFoundException { PrintStream out = new PrintStream(file); out.print(text); out.close(); } }