Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > a basic NIO Question

Reply
Thread Tools

a basic NIO Question

 
 
dhek bhun kho
Guest
Posts: n/a
 
      07-26-2003
"Shripathi Kamath" <(E-Mail Removed)>, Sat, 26 Jul 2003
10:21:49 -0700:

> "VX" <(E-Mail Removed)> wrote in message
> news:VRxUa.263$(E-Mail Removed)...
>> 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.
 
Reply With Quote
 
 
 
 
VX
Guest
Posts: n/a
 
      07-26-2003
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


 
Reply With Quote
 
 
 
 
xarax
Guest
Posts: n/a
 
      07-26-2003
"VX" <(E-Mail Removed)> wrote in message news:<VRxUa.263$(E-Mail Removed)>. ..
> 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.
 
Reply With Quote
 
VX
Guest
Posts: n/a
 
      07-27-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "VX" <(E-Mail Removed)> wrote in message

news:<VRxUa.263$(E-Mail Removed)>. ..
> > 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about non-blocking NIO and Selection Keys Zachary Turner Java 12 07-03-2008 02:01 PM
question for use java nio to get the data from rss link? wuweipku@gmail.com Java 4 11-09-2006 03:46 AM
NIO with timeouts != NIO? iksrazal Java 1 06-18-2004 02:28 PM
Question about rationale for java.nio.Buffer design. Harald Kirsch Java 0 06-14-2004 12:15 PM
java.nio as opposed to java.net - basic difference in program logic? Chris Berg Java 1 11-23-2003 11:09 PM



Advertisments