Reputation: 13118
From the official API:
Do you know any real case where the following constructor would be actually useful? FileReader
public FileReader(FileDescriptor fd)
Creates a new FileReader, given the FileDescriptor to read from.
Parameters:
fd - the FileDescriptor to read from
Thanks in advance.
Upvotes: 0
Views: 417
Reputation: 298489
There are two uses:
Access to the standard streams, e.g.
FileWriter fw=new FileWriter(FileDescriptor.out);`
Access to the same file of an existing stream, e.g.
FileInputStream is= … ;
FileReader r=new FileReader(is.getFD());
This works even with having reading and writing streams on a file at the same time. You can also create streams or readers/writers to an existing RandomAccessFile
. Unfortunately, FileReader
and FileWriter
lack the getFD()
method which the other classes have.
Upvotes: 1