Java 'Write' and Java 'Read'

Feb 6, 2008 at 3:47pm

Java 'Write' and Java 'Read'

Feb 6, 2008 at 4:07pm

On 6 Feb 2008, at 15:47, David Roden wrote:

> for(int i = 0; i < (4 * arraySize); i++)
> {
> while(i < arraySize)
> {pBank[i] = sc.nextInt();}

You’re doing “while” tests on the control variable of a for-loop, so
I’m surprised you’re not just running into an infinite loop, unless
some of the initialisation is wrong.

I think this entire read loop needs to be restructured: what’s wrong
with four loops in succession?

– N.

Nick Rothwell / Limited

Feb 6, 2008 at 6:12pm

Moving this thread to the Java forum.

Feb 9, 2008 at 10:15am

Thanks Nick.

You’re right of course about the overly complicated loop, though that wasn’t the source of the difficulty.

I’ve subsequently worked around it by backing up the arrays to dat files using DataOutPutStream. I’ve kept the text write method in as it was a handy debugging tool while tweaking my new Import and Export methods!


You must be logged in to reply to this topic.