🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#8427
From: Ben Matterson (Borland)
Date: Tue, 20 Mar 2001 22:33
33 lines
1804 bytes

Herbert Carl Meyer wrote:
> 
> Start from:
> 
> public int InputStream.read( byte[] b) throws IOException

Yep, that's what I did.

> So pick a number for the size of b, read a chunk at a time, and copy bytes
> from b to the end of something else, 

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.

> Read the JDK javadoc for java.io for details. 

Yep.

> And don't panic.

Sound advice in any situation.

Ben
-- 
InterBase Technical Support
Borland Software Corp.
Technical Details
Message-ID: <3AB7DABB.29AA6493@borland.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!sunqbc.risq.qc.ca!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!10.143.12.142
References: <3AB7BC0C.60473976@borland.com> <3AB7D121.4496BC68@mediaone.net>

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 03:56:06 PST
Message-ID: <3AB7DABB.29AA6493@borland.com>
Date: Tue, 20 Mar 2001 14:33:31 -0800
From: "Ben Matterson (Borland)" <bmatterson@borland.com>
Organization: Borland Software Corp
X-Mailer: Mozilla 4.7 [en] (Win98; 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>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.143.12.142
X-Trace: 20 Mar 2001 14:33:29 -0800, 10.143.12.142
Lines: 33
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!sunqbc.risq.qc.ca!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!10.143.12.142