🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8459

Re: How can I read in file into a byte array?

#8459
From: Herbert Carl Meyer
Date: Thu, 22 Mar 2001 14:45
25 lines
2054 bytes
>
> How big would I make that "something else"? That was my main question,
> how do I know how big to make the array of bytes such that I don't
> overrun the end of the array?
>
> To maybe answer my own question, it looks like the File class might do
> what I want using the length() method. I create a new File, then
> create an InputStream using the File.
>

Thinking more, I came up with an approach that would loop, "new" a new b every
pass, and add b to a vector collection object after b was read. After file was
exhausted, iterate thru the collection, sum sizes, allocate a large block, the
arraycopy from the b's. Will end up temporally using twice the amount of storage
(plus a bit for the collection object). If you use the fileSize, add padding
(5~10% ?), the size may not be absolutely accurate.

What are you doing ? I see Interbase, are you sucking a blob out of a database ?

> > And don't panic.
>
> Sound advice in any situation.
>

And keep a dry towel handy.
Technical Details
Message-ID: <3ABA1026.F81B68C@mediaone.net>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!zeus.visi.com!news-out.visi.com!hermes.visi.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!64.105.70.175
References: <3AB7BC0C.60473976@borland.com> <3AB7D121.4496BC68@mediaone.net> <3AB7DABB.29AA6493@borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,2ea00c6aa2f0fa5a
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-23 04:06:07 PST
Message-ID: <3ABA1026.F81B68C@mediaone.net>
Date: Thu, 22 Mar 2001 08:45:58 -0600
From: Herbert Carl Meyer <hcMeyer@mediaone.net>
Reply-To: hcMeyer@mediaone.net
Organization: Dickson/Unigage
X-Mailer: Mozilla 4.76 [en]C-CCK-MCD NSCPCD47  (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: How can I read in file into a byte array?
References: <3AB7BC0C.60473976@borland.com> <3AB7D121.4496BC68@mediaone.net> <3AB7DABB.29AA6493@borland.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 64.105.70.175
X-Trace: 22 Mar 2001 06:49:58 -0800, 64.105.70.175
Lines: 26
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!zeus.visi.com!news-out.visi.com!hermes.visi.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!64.105.70.175