Question about File Descripters

I am new to Java so forgive my ignorance...I was wondering that why this FileDescriptor class is all about? anyone give me any example(easy) I am new.. but don't worry.. i know java io streams well...I will appreciate you help!!MOIN.
[269 byte] By [moin_khan] at [2007-9-27 21:10:30]
# 1
Here's what FileDescriptor is all about http://java.sun.com/j2se/1.4.1/docs/api/java/io/FileDescriptor.htmlHere's an example http://developer.java.sun.com/developer/TechTips/1998/tt0421.html#tip2
bbritta at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 2
As it says in the javadoc FileDescriptor is basically a representation of some platform-specific resource, like a socket or a file. I think it probably lets java do I/O faster
tjacobs01 at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 3
Thankyou very much for your links.. but what's the use of it? Don't you think that File Class can do much more than that?It just hides some device specific information. that's what File class does.. then why use FileDescriptor.. and it only supports two methods..
moin_khan at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 4
AnyOne please?
moin_khan at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 5

If there is a class that does all you need and a class that does that and more its "better programming" to use the simpler one

also FileDecriptor will provide the same interface for an open File, an open Socket or any othet source or sink of bytes. so you could use the same class for all these rather than separate classes for each type of stream (basic principal of OOP, make things act as similar as possible)

Pete_The_Hat at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 6

Thank you very much!!!

So you mean that FileDescriptor can stand for ANY OS object (like socket, devices, like printer) and File Object doesn't..OK i got the difference... but What's the use of FileDescriptor?

u said that i provides same interface.. but where is the interface.?. there are only two methods.. sync and valid().. use can't use FileDescriptor to do any operations on the object then what's the use?

I am sorry if i am too much silly!! but i am new to Java...:)

moin_khan at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 7
Anyone please!!! Help me out!!!
moin_khan at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 8
***BUMP****C'Mon GURUS.....
moin_khan at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...
# 9

Hi!

As long as I know, the main use of a FileDescriptor is to ensure the flushing of file buffers to disk by using the sync() method.

It is, if you have a FileOutputStream (or any stream connected to it) you cannot be sure that calling the flush() method will flush O.S. buffers to disk. The only way to do that is by means of:

FileOutputStream out = new FileOutputStream( "xxx.yyy" );

.... // write here your data

// The following only flushes FileOutputStream buffers (if any)

out.flush();

// Try to flush O.S. buffers

out.getFD().sync();

Take a look at "JAVA I/O" by E. R. Harold for more info.

Bye.

ezavalla at 2007-7-7 3:01:09 > top of Java-index,Archived Forums,Java Programming...