Computer Science Canada List Doesnt Fully Write |
Author: | Omnipotence [ Mon Nov 27, 2006 7:01 pm ] | ||
Post subject: | List Doesnt Fully Write | ||
I coded this thing to build a list of every file in a folder (Which would be inputed) and it would number all the files and write it to a .txt file. The only trouble is, the list keeps cutting somewhere 5/6ths of the way (guessing estimate) and I can't seem to figure out why. I checked the number of times the for loop went through and even if the program picked out the last item, but I still cant get it to write. Any ideas?
Mod's note: please use code tags.[/i] |
Author: | wtd [ Mon Nov 27, 2006 7:21 pm ] | ||
Post subject: | |||
Let's try formatting this so it looks like Java code.
Now, we can start looking for semantic problems. |
Author: | Neville [ Fri Dec 01, 2006 10:51 pm ] | ||
Post subject: | |||
The main problem I see is that your counting variable, indx, goes from 1 to ( sortingList.length - 1 ). Since you actually print the array like so: sortingList[indx-1], indx should go all the way to sortingList.length. Therefore...
That should get the last file taken care of. If you are missing more than one file, then something else is wrong (check the size of sortingList.length vs. the actual number of files in the directory). |
Author: | Aziz [ Sat Dec 02, 2006 4:38 pm ] | ||
Post subject: | |||
In java (and most other languages) arrays start at 0. To access every value in an array:
also, look up the for each loop. |