Constructors | Description |
---|---|
FileReader( File file) | Creates a new FileReader and given the file to read from. |
FileReader(FileDescriptor fd) | Creates a new file with FileDescriptor to read from. |
FileReader(String filename) | Creates a new FileReader, given the name of the file to read from. |
import java.io.*;
public class FileReaderDemo
{
public static void main(String args[])throws FileNotFoundException, IOException
{
FileReader fr = new FileReader("abc.txt");
int i;
System.out.println("ASCII value of the character:");
while((i=fr.read()) != -1)
{
System.out.print(i+" : ");
System.out.println ((char)i);
}
}
}
Constructors | Description |
---|---|
FileWriter( File file) | It constructs a FileWriter object given a file object. |
FileWriter(FileDescriptor fd) | It creates a FileWriter object with file descriptor. |
FileWriter(String filename) | Creates a FileWriter object with specified file name. |
FileWriter(File file, boolean append) | Creates a FileWriter object given by a file object. |
FileWriter(String filename, boolean append) | Creates the FileWriter object given a file name. |
import java.io.*;
public class FileWriterDemo
{
public static void main(String args[]) throws IOException
{
FileWriter fw = new FileWriter("abc.txt");
char c = 'a';
fw.write(c);
System.out.println("Character "+c+" is write in file");
fw.close();
}
}