Forums > Java

Java 'Write' and Java 'Read'

February 6, 2008 | 3:47 pm


February 6, 2008 | 4:07 pm

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 / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net


February 6, 2008 | 6:12 pm

Moving this thread to the Java forum.


February 9, 2008 | 10:15 am

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!


Viewing 4 posts - 1 through 4 (of 4 total)