FileDescriptor

Discussion in 'Java' started by bob smith, Oct 12, 2012.

  1. bob smith

    bob smith Guest

    Can someone help me understand the class FileDescriptor?

    Seems like it is mainly a wrapper for this:

    private int fd;

    But there's no obvious way to access or set that value. Am I missing something?
    bob smith, Oct 12, 2012
    #1
    1. Advertising

  2. bob smith

    Daniel Pitts Guest

    On 10/12/12 3:23 PM, bob smith wrote:
    > Can someone help me understand the class FileDescriptor?
    >
    > Seems like it is mainly a wrapper for this:
    >
    > private int fd;
    >
    > But there's no obvious way to access or set that value. Am I missing something?
    >

    What would you do with that value? It is generally opaque, and only
    useful to pass through to other methods which already take the
    FileDescriptor object.
    Daniel Pitts, Oct 12, 2012
    #2
    1. Advertising

  3. bob smith

    Arne Vajhøj Guest

    On 10/12/2012 6:23 PM, bob smith wrote:
    > Can someone help me understand the class FileDescriptor?
    >
    > Seems like it is mainly a wrapper for this:
    >
    > private int fd;
    >
    > But there's no obvious way to access or set that value. Am I missing something?


    To quote the docs:

    <docs>
    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.
    </docs>

    You can get it out from a File*Stream and you can use it to
    construct a new File*Stream.

    But what it contains is implementation specific and hidden
    from you.

    Good OOP.

    On various *nix and *nix-like OS'es it could be a traditional
    int fd.

    Arne
    Arne Vajhøj, Oct 13, 2012
    #3
  4. bob smith

    Roedy Green Guest

    On Fri, 12 Oct 2012 15:23:37 -0700 (PDT), bob smith
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Can someone help me understand the class FileDescriptor?


    It is not a class you would use directly. It provides a way to hold a
    platform-specific handle to an open file.

    At the assembler level in Windows, when you open a file, Windows gives
    you an int handle to use to read/write. You don't specify the full
    filename each time or read or write, just the handle.
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    The iPhone 5 is a low end Rolex.
    Roedy Green, Oct 13, 2012
    #4
  5. bob smith

    Arne Vajhoej Guest

    On 10/13/2012 4:58 PM, Roedy Green wrote:
    > On Fri, 12 Oct 2012 15:23:37 -0700 (PDT), bob smith
    > <> wrote, quoted or indirectly quoted someone
    > who said :
    >> Can someone help me understand the class FileDescriptor?

    >
    > It is not a class you would use directly. It provides a way to hold a
    > platform-specific handle to an open file.


    So far so good.

    > At the assembler level in Windows,


    Nope. C level.

    > when you open a file, Windows gives
    > you an int handle to use to read/write. You don't specify the full
    > filename each time or read or write, just the handle.


    That is like almost all languages and all API's.

    Arne
    Arne Vajhoej, Oct 13, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paolo Invernizzi

    filedescriptor out of range in select()

    Paolo Invernizzi, Jun 26, 2003, in forum: Python
    Replies:
    0
    Views:
    897
    Paolo Invernizzi
    Jun 26, 2003
  2. Andrew Bennetts

    Re: filedescriptor out of range in select()

    Andrew Bennetts, Jun 26, 2003, in forum: Python
    Replies:
    5
    Views:
    5,059
    Paolo Invernizzi
    Jun 30, 2003
  3. Replies:
    1
    Views:
    314
    Jack Klein
    Sep 16, 2006
  4. Laszlo Nagy
    Replies:
    0
    Views:
    373
    Laszlo Nagy
    Mar 17, 2009
  5. Laszlo Nagy
    Replies:
    0
    Views:
    433
    Laszlo Nagy
    Mar 17, 2009
Loading...

Share This Page