a basic NIO Question

Discussion in 'Java' started by dhek bhun kho, Jul 26, 2003.

  1. "Shripathi Kamath" <>, Sat, 26 Jul 2003
    10:21:49 -0700:

    > "VX" <> wrote in message
    > news:VRxUa.263$...
    >> I have a very elementary question about java.nio classes
    >> the ByteBuffer class is created using:
    >> ByteBuffer.allocate(int bytes);
    >> I am trying to open a file with a file size greater than an int can hold.

    > if
    >> i round the file length to an integer, i get an IndexOutOfBound exception.
    >>
    >> Thanks in advance
    >>

    >
    >
    > What's your question? Please illustrate with code snippets.


    That's not the problem. The problem is that the ByteBuffer.class can not
    allocate a buffer longer than Integer.MAX_VALUE. And the file is longer
    than that. I do not know the answer, but if I had the problem I would use
    a smaller byte buffers to provide a view into the file.

    Greets
    Bhun.
    dhek bhun kho, Jul 26, 2003
    #1
    1. Advertising

  2. dhek bhun kho

    VX Guest

    I have a very elementary question about java.nio classes
    the ByteBuffer class is created using:
    ByteBuffer.allocate(int bytes);
    I am trying to open a file with a file size greater than an int can hold. if
    i round the file length to an integer, i get an IndexOutOfBound exception.

    Thanks in advance
    VX, Jul 26, 2003
    #2
    1. Advertising

  3. dhek bhun kho

    xarax Guest

    "VX" <> wrote in message news:<VRxUa.263$>...
    > I have a very elementary question about java.nio classes
    > the ByteBuffer class is created using:
    > ByteBuffer.allocate(int bytes);
    > I am trying to open a file with a file size greater than an int can hold. if
    > i round the file length to an integer, i get an IndexOutOfBound exception.
    >
    > Thanks in advance


    ByteBuffer is not used to buffer the entire file. It is only
    used to buffer logical records within the file. Most applications
    process logical records in memory, not the entire file.

    You need to rethink your design.
    xarax, Jul 26, 2003
    #3
  4. dhek bhun kho

    VX Guest

    Thanks for your suggestions...actually, its my second day with nio package
    (and i am still learning) and i was just concentrating on the ByteBuffer
    class.
    Thanks, all of u

    "xarax" <> wrote in message
    news:...
    > "VX" <> wrote in message

    news:<VRxUa.263$>...
    > > I have a very elementary question about java.nio classes
    > > the ByteBuffer class is created using:
    > > ByteBuffer.allocate(int bytes);
    > > I am trying to open a file with a file size greater than an int can

    hold. if
    > > i round the file length to an integer, i get an IndexOutOfBound

    exception.
    > >
    > > Thanks in advance

    >
    > ByteBuffer is not used to buffer the entire file. It is only
    > used to buffer logical records within the file. Most applications
    > process logical records in memory, not the entire file.
    >
    > You need to rethink your design.
    VX, Jul 27, 2003
    #4
    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. Chris Berg
    Replies:
    1
    Views:
    512
    Sudsy
    Nov 23, 2003
  2. Harald Kirsch
    Replies:
    0
    Views:
    373
    Harald Kirsch
    Jun 14, 2004
  3. iksrazal

    NIO with timeouts != NIO?

    iksrazal, Jun 17, 2004, in forum: Java
    Replies:
    1
    Views:
    6,248
    iksrazal
    Jun 18, 2004
  4. Replies:
    4
    Views:
    406
  5. Zachary  Turner
    Replies:
    12
    Views:
    519
    Arne Vajhøj
    Jul 3, 2008
Loading...

Share This Page