将文件写入硬盘。从文件读取UTF8
/* ----------------------------------------------------------------------------=== * * Part of the InfoGlue Content Management Platform (www.infoglue.org) * * ----------------------------------------------------------------------------=== * * Copyright (C) * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 2, as published by the * Free Software Foundation. See the file LICENSE.html for more information. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple * Place, Suite 330 / Boston, MA 02111-1307 / USA. * * ----------------------------------------------------------------------------=== */ //package com.nowjava; /* nowjava.com - 时 代 Java */ import java.io.*; public class Main { /** * Writes the file to the hard disk. If the file doesn't exist a new file is created. * @author Mattias Bogeblad * @param text The text you want to write to the file. * @param file The file to save to * @param is_append Dictates if the text should be appended to the existing file. * If is_append == true; The text will be added to the existing file. * If is_append == false; The text will overwrite the existing contents of the file. * * @exception java.lang.Exception * @since 2002-12-12 */ public synchronized static String readUTF8FromFile(File file) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(file), "UTF8"));