Article View: borland.public.jbuilder.java.api
Article #988Re: OutOfMemoryError
From: Alan Shiers
Date: Tue, 02 Jul 2002 18:10
Date: Tue, 02 Jul 2002 18:10
24 lines
1815 bytes
1815 bytes
Hi Gilmer, "Gillmer J. Derge [TeamB]" wrote: > Now there's no buffer, and your process only needs to remember one byte at > a time. Then I'd change this again to do the same thing but in blocks of N > (ex. N=64 or N=128) bytes instead of one at a time. > > byte[] buffer = new byte[128]; > int n; > while ((n = in.read(buffer)) >= 0) > out.write(buffer, n); This while loop is confusing to me. You dimension an array at 128 elements and pass it to the read(byte[]) method of DataInputStream. Where does the size of the file figure into all this? The thing that is throwing me is that the file maybe much bigger than 128bytes. Is the read() method going to automatically increase the size of the array? I don't get it! Alan
Technical Details
Message-ID:
<3D21EC78.228A5CD3@hfx.eastlink.ca>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!novia!novia!btnet-peer1!btnet!isdnet!skynet.be!skynet.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3D20CC5D.B70473C9@hfx.eastlink.ca> <MPG.178acb912dba8f7998b79d@newsgroups.borland.com> <3D21C1CA.F2D953E2@hfx.eastlink.ca> <3d21bb44_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,28eab50e784856ac X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-07-02 10:12:49 PST Message-ID: <3D21EC78.228A5CD3@hfx.eastlink.ca> Date: Tue, 02 Jul 2002 14:10:00 -0400 From: Alan Shiers <ashiers@hfx.eastlink.ca> Organization: Mustard Seed Software X-Mailer: Mozilla 4.78 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.api Subject: Re: OutOfMemoryError References: <3D20CC5D.B70473C9@hfx.eastlink.ca> <MPG.178acb912dba8f7998b79d@newsgroups.borland.com> <3D21C1CA.F2D953E2@hfx.eastlink.ca> <3d21bb44_1@dnews> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.222.101.2 X-Trace: dnews 1025629637 24.222.101.2 (2 Jul 2002 10:07:17 -0700) Lines: 24 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!novia!novia!btnet-peer1!btnet!isdnet!skynet.be!skynet.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews