Article View: aus.computers.java
Article #674Re: Array problem- struggling 1st Year student
From: Alan Boldock
Date: Thu, 18 May 2000 00:00
Date: Thu, 18 May 2000 00:00
37 lines
2129 bytes
2129 bytes
Perhaps you should read your streamTokzenizer and retrieve each word and either stuff them in a Vector or read the file twice and do it the first time just to get the word count. Use this word count to initialise your array (to that size) then read the file again putting each word into the Array. A better one pass approach would be to read each word into a Vector (You don't need to initialise a Vector with a size) then at the end get the vector size, make the array then use the Vector.copyInto(Object[]) method to read your Vector into your array. There are more sophisticated approaches but for a beginner this is an easy conceptual approach. Alan "Funtybugwana" <funtybugwana@icqmail.com> wrote in message news:L1lU4.43$GC4.489545@news0.optus.net.au... > Can one of you good people please give me a pointer on how to initialise an > array with information which I have pulled from a text file.. > > The assignment which I have been given is to use arrays to pull all words > from any document, count occurences of the word and sort it in order..Not a > hard task.. well Im dying.. > > I have used streamTokeniser to pull in the document using a GUI interface > which is great but thats about it, I cannot work out how to get that info > into the array with the text book and lecture notes given... Please help me > > Mark > >
Technical Details
Message-ID:
<lGHU4.35613$PL4.717065@ozemail.com.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<L1lU4.43$GC4.489545@news0.optus.net.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,c27ec22d2383b153 X-Google-Attributes: gid10d6db,public From: "Alan Boldock" <aboldock@camtech.net.au> Subject: Re: Array problem- struggling 1st Year student Date: 2000/05/18 Message-ID: <lGHU4.35613$PL4.717065@ozemail.com.au> X-Deja-AN: 624789542 Distribution: world References: <L1lU4.43$GC4.489545@news0.optus.net.au> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Trace: ozemail.com.au 958613265 203.38.172.194 (Thu, 18 May 2000 11:27:45 EST) Organization: www.boldenterprise.com.au X-MSMail-Priority: Normal Reply-To: "Alan Boldock" <aboldock@camtech.net.au> NNTP-Posting-Date: Thu, 18 May 2000 11:27:45 EST Newsgroups: aus.computers.java