Here you can find the source of writeFile(String txt, File fyl)
Parameter | Description |
---|---|
txt | the text to output to file. |
fyl | the file to write to. |
Parameter | Description |
---|---|
FileNotFoundException | , IOException if something goes wrong. |
public synchronized static void writeFile(String txt, File fyl) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { /**/*from w w w .ja v a 2 s. c o m*/ * Write a file. * @param txt the text to output to file. * @param fyl the file to write to. * @throws FileNotFoundException, IOException if something goes wrong. */ public synchronized static void writeFile(String txt, File fyl) throws FileNotFoundException, IOException { writeFile(txt.getBytes(), fyl); } /** * Write a file. * @param bites the array of bytes to output to file. * @param fyl the file to write to. * @throws FileNotFoundException, IOException if something goes wrong. */ public synchronized static void writeFile(byte[] bites, File fyl) throws FileNotFoundException, IOException { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fyl)); bos.write(bites); bos.flush(); bos.close(); } }