Java.io - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Java.io FileWriter

Java.io FileWriter

shape Introduction

Java.io FileWriter is the class used for writing content of files in characters. Java.io FileWriter having the feature to write streams of characters from file or directory. Whereas for the purpose of writing bytes of stream, FileOutputStream is used. The default character encoding scheme is only possible in case of Java.io FileWriter. To specify a different character encoding scheme then use OutputStreamWriter.

shape Conceptual figure

The function of file writer is shown in above figure.

Class Declaration

shape Declaration

Java.io FileWriter class is declared as shown below: Public class FileWriter extends OutputStreamWriter

shape Fields

Following is the field for Java.io.FileWriter class:
  • protected Object lock : For synchronize operations this object lock is used in FileWriter.

Class Constructors

shape Table

Constructor Description
FileWriter (File file) The function of this constructor is to construct the file write object and writes the given file.
FileWriter(String FileName) This constructor creates a FileWriter object and the FileName is given to write.
FileWriter(FileDescriptor fd) This constructor creates a FileWriter object and the FileDescriptor is given to write.
FileWriter (File file,Boolean append) A file writer object is created by this constructor and writes the given file.
FileWriter(String fileName, boolean append) A file writer object is created by this constructor and the file name which is indicated by the boolean is used to add the data written or not.

Inherited Methods

shape Description

From the following classes, methods are inherited to Java.io.FileWriter
  • Java.io.OutputStreamWriter
  • java.uti.Writer
  • Java.io.Object

Summary

shape Key Points

  • Java.io.FileWriter is the class used for writing content of files in characters.
  • FileWriter having the feature to write streams of characters from file or directory.
  • The default character encoding scheme is only possible in case of FileWriter. To specify a different character encoding scheme then use OutputStreamWriter.