What's the use of FileDescriptor class in Java and its in,out and err methods?
What's the use of the FileDescriptor class in Java ? We can only obtain开发者_Go百科 it with the getFD() methods on streams and then we can use the obtained FD to create another instance of, say, FileInputStream which we can also do by creating a FileInputStream object with the same file name (instead of using its FD).
Also, the methods in, out and err. what use can they be put to ?
As the JavaDoc says:
Instances of the file descriptor class serve as an opaque handle to the underlying machine-specific structure representing an open file, an open socket, or another source or sink of bytes. The main practical use for a file descriptor is to create a FileInputStream or FileOutputStream to contain it.
Applications should not create their own file descriptors.
They are therefore a behind-the-scenes implementation detail for the JDK to plug in to the underlying OS
精彩评论