Here you can find the source of writeFile(File file, String content)
Parameter | Description |
---|---|
file | The file name |
content | The content of the new file |
public static void writeFile(File file, String content) throws IOException
//package com.java2s; /**// www . j a va 2 s.co m * Copyright (c) 2009 University of Rochester * * This program is free software; you can redistribute it and/or modify it under the terms of the MIT/X11 license. The text of the * license can be found at http://www.opensource.org/licenses/mit-license.php and copy of the license can be found on the project * website http://www.extensiblecatalog.org/. * */ import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; public class Main { /** * Write content to file * * @param file The file name * @param content The content of the new file */ public static void writeFile(File file, String content) throws IOException { Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); out.write(content); out.close(); } }