English 中文(简体)
Java.io package classes

Java.io package extras

Java.io package Useful Resources

Selected Reading

Java.io - FileWriter
  • 时间:2024-09-17

Java.io.FileWriter Class


Previous Page Next Page  

Introduction

The Java.io.FileWriter class is a convenience class for writing character files.Following are the important points about FileWriter −

    The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable.

    FileWriter is meant for writing streams of characters. For writing streams of raw bytes, use FileOutputStream.

Class declaration

Following is the declaration for Java.io.FileWriter class −

pubpc class FileWriter
   extends OutputStreamWriter

Field

Following are the fields for Java.io.FileWriter class −

    protected Object lock − This is the object used to synchronize operations on this stream.

Class constructors

Sr.No. Constructor & Description
1

FileWriter(File file)

This constructs a FileWriter object given a File object.

2

FileWriter(File file, boolean append)

This constructs a FileWriter object given a File object.

3

FileWriter(FileDescriptor fd)

This constructs a FileWriter object associated with a file descriptor.

4

FileWriter(String fileName)

This constructs a FileWriter object given a file name.

5

FileWriter(String fileName, boolean append)

This constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written.

Class Methods

This class inherits methods from the following classes −

    Java.io.OutputStreamWriter

    java.uti.Writer

    Java.io.Object

Advertisements