Java资源网

| JAVA基础 | 环境配置 | JDBC | 线程技术 | Socket编程 | JavaMail | JAVA与XML | 设计模式 | 技术新闻 | Java认证 | 程序人生 软件下载
| JSP&Servlet | Spring | Struts | Hibernate | JBuilder | Eclipse | WebService | EJB技术 | J2ME开发 | 应用服务器 | JXTA | Ajax
Articles search文章搜索
   关键字:
   类 别:
       
New download 最新下载
· [组件]HTML Parser 1.5
· [教程]WebSphere Studio应用教程
· [组件]JDom 1.0
· [工具]Junit3.8.1
· [教程]EJB编程及J2EE系统架构和设计
· [教程]EJB教程
· [教程]J2EE Tutorial中文版
· [教程]Java编程思想2(英文)
· [教程]java编程思想(完整版)
· [教程]Java网络编程
New articles 最新文章
· 设计移动 Web 服务
· 解析XML的时候完全忽略DTD
· 理解XML Schema XML Schema 初步
· 标签库的深入研究
· 提升JSP应用程序的七大绝招
· 如何使用JDOM对XML文件进行操作
· 处理XML字符串中特殊字符
· 利用Digester把XML转换成为Java对象
· 使用WebService 和RMI远程协作
· 使用Axis开发Web Service程序
Articles top 热门文章
· Eclipse基础--plugin插件安装(6644)
· eclipse+tomcat+lomboz的安装配置说明(4774)
· Java程序员就业前景(4584)
· Windows下JAVA环境变量的设置祥解(3788)
· Tomcat下JSP、Servlet和JavaBean环境的配置(3716)
· 使用links方式安装Eclipse插件(3698)
· 一个老程序员的心理话(3533)
· linux下jdk的安装与配置(3459)
· 初学者入门:Structs中基本配置入门(3334)
· Eclipse 运行命令行参数大全(3084)
您的位置:首页>>JAVA基础>>java.io.FileWriter翻译
java.io.FileWriter翻译
2005-08-24   来源:CSDN  作者:wongdongfanglai
 
 

java.io
Class FileWriter

java.lang.Object
  java.io.Writer
      java.io.OutputStreamWriter
          java.io.FileWriter

public class FileWriter
extends OutputStreamWriter

Convenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream. 输出字符文件的工具类。该类的构造函数假定默认的字符编码和默认的字节缓冲大小是合适的。如果自己要指定这些值,应该基于FileOutStream构造一个OutStreamWriter。

Whether or not a file is available or may be created depends upon the underlying platform. Some platforms, in particular, allow a file to be opened for writing by only one FileWriter (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open. 文件是否可用或可创建依赖于底层平台。特别地,某些平台只允许FileWriter或者其它文件输出对象打开该文件一次用于输出。在这种情况下如果调用的文件已被打开,类的构造函数将会失败。

FileWriter is meant for writing streams of characters. For writing streams of raw bytes, consider using a FileOutputStream. FileWriter是读取字符流的工具。如果输出字节流,应该考虑采用FileOutputStream。

Since:
JDK1.1
See Also:
OutputStreamWriter, FileOutputStream

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
FileWriter(File file)
          Constructs a FileWriter object given a File object. 构建一个给定File对象的FileWriter对象。
FileWriter(File file, boolean append)
          Constructs a FileWriter object given a File object. 构建一个给定File对象的FileWriter对象。
FileWriter(FileDescriptor fd)
          Constructs a FileWriter object associated with a file descriptor. 构建一个与文件描述符关联的FileWriter对象。
FileWriter(String fileName)
          Constructs a FileWriter object given a file name. 构建一个给定文件名的FileWriter对象。
FileWriter(String fileName, boolean append)
          Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written. 构建一个给定文件名的FileWriter对象,使用布尔值标识是否附加写入的数据。
 
Methods inherited from class java.io.OutputStreamWriter
close, flush, getEncoding, write, write, write
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileWriter

public FileWriter(String fileName)
           throws IOException
Constructs a FileWriter object given a file name. 构建一个给定文件名的FileWriter对象。

Parameters:
fileName - String The system-dependent filename. 字符串,系统相关的文件名。
Throws:
IOException - if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason 如果该名称的文件存在但是是目录而不是常规文件,或者不存在但不能被创建, 或者其他原因不能打开,则抛出

FileWriter

public FileWriter(String fileName,
                  boolean append)
           throws IOException
Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written. 构建一个给定文件名的FileWriter对象,使用布尔值标识是否附加写入的数据。

Parameters:
fileName - String The system-dependent filename. 字符串,系统相关的文件名。
append - boolean if true, then data will be written to the end of the file rather than the beginning. 如果布尔值为true,那么数据将被输出至文件末尾而不是开头。
Throws:
IOException - if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason 如果该名称的文件存在但是是目录而不是常规文件,或者不存在但不能被创建, 或者其他原因不能打开,则抛出

FileWriter

public FileWriter(File file)
           throws IOException
Constructs a FileWriter object given a File object. 构建一个给定File对象的FileWriter对象。

Parameters:
file - a File object to write to. 要输出的File对象。
Throws:
IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason 如果该文件存在但是是目录而不是常规文件,或者不存在但不能被创建, 或者其他原因不能打开,则抛出

FileWriter

public FileWriter(File file,
                  boolean append)
           throws IOException
Constructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. 构建一个给定File对象的FileWriter对象。如果第二个参数为true,那么字节将被输出至文件末尾而不是开头。

Parameters:
file - a File object to write to 要输出的File对象
append - if true, then bytes will be written to the end of the file rather than the beginning 如果为true,那么字节将被输出至文件末尾而不是开头。
Throws:
IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason 如果该文件存在但是是目录而不是常规文件,或者不存在但不能被创建, 或者其他原因不能打开,则抛出
Since:
1.4

FileWriter

public FileWriter(FileDescriptor fd)
Constructs a FileWriter object associated with a file descriptor. 构建一个与文件描述符关联的FileWriter对象。

Parameters:
fd - FileDescriptor object to write to. 要输出的FileDescriptor对象。

 

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

  --相关文章--
· J2EE全面介绍(二) (2007-04-13)
· 项目经验二则:读取war包中的文件及Ant使用中的OutOfMemoryError解决 (2007-04-13)
· 走向J2EE,漫长的道路 (2007-04-13)
· 步入J2EE架构和过程(2) (2007-04-13)
· 步入J2EE架构和过程(1) (2007-04-13)
· 方兴未艾的CORBA (2007-04-13)

版权所有©2005-2006 JAVA资源网 渝ICP备05007591号 虚拟主机 | 关于我们 | 联系方式 | 广告业务 | 网站地图 | 友情链接