Article View: borland.public.jbuilder.java.language
Article #8341Re: How can I read in file into a byte array?
From: Nabin Thomas
Date: Sun, 01 Apr 2001 14:47
Date: Sun, 01 Apr 2001 14:47
58 lines
2951 bytes
2951 bytes
This is a multi-part message in MIME format. --------------39FF9D6B42CF3D423B389D62 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Herbert Carl Meyer wrote: > > > > 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. > Why is it so ? > > 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. --------------39FF9D6B42CF3D423B389D62 Content-Type: text/x-vcard; charset=us-ascii; name="viewmycard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Nabin Thomas Content-Disposition: attachment; filename="viewmycard.vcf" begin:vcard n:Thomas;Nabin x-mozilla-html:TRUE adr:;;;;;; version:2.1 email;internet:DONOTSPAMME.nabinthomas@REMOVETHIShotmail.comANDTHISTOO note;quoted-printable:REMOVE the Capitalised letters in my email ID given in this card=0D=0A=0D=0AFeel free to contact me thru e-mail or MSN Mssenger =0D=0A if required but DONOT SPAM=0D=0A=0D=0A fn:Nabin Thomas end:vcard --------------39FF9D6B42CF3D423B389D62--
Technical Details
Message-ID:
<3AC73F77.B55D5F24@foremail.nospamplease>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.tele.dk!194.213.69.151!news.algonet.se!algonet!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!202.86.153.108References:
<3AB7BC0C.60473976@borland.com> <3AB7D121.4496BC68@mediaone.net> <3AB7DABB.29AA6493@borland.com> <3ABA1026.F81B68C@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-04-01 20:54:03 PST Message-ID: <3AC73F77.B55D5F24@foremail.nospamplease> Date: Sun, 01 Apr 2001 20:17:19 +0530 From: Nabin Thomas <viewmycard@foremail.nospamplease> X-Mailer: Mozilla 4.76 [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> <3AB7DABB.29AA6493@borland.com> <3ABA1026.F81B68C@mediaone.net> Content-Type: multipart/mixed; boundary="------------39FF9D6B42CF3D423B389D62" NNTP-Posting-Host: 202.86.153.108 X-Trace: 1 Apr 2001 20:17:38 -0800, 202.86.153.108 Lines: 61 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.tele.dk!194.213.69.151!news.algonet.se!algonet!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!202.86.153.108