Results 1 to 2 of 2
Thread: Problem with array Copy
- 08-07-2007, 03:43 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 39
- Rep Power
- 0
Problem with array Copy
Please check this:
Java Code:String FOLDER_LIST[] = {"Test1", "Test2", "Test3", "Test4"}; for(int i = 0; i<FOLDER_LIST.length; i++){ tmp[][] = getFileCOntent(new File(drives["C:\\" + FOLDER_LIST + "\\")); }
The above is supposed to go to all the 4 folders in the C:\ and copy the contents into a tmp array.. and then pass it to the final array..
The getFileCOntent() method takes in a File type, and gets all the files in the directory and stores and returns a 2D array to fill a jtable with the rows and columns..
The only problem i have is every time it does the loop, it wipes the contents of the files from the previous folders, only the last folder content is stored.. which is "Test4", how do I get the content of all the folders?
Thanks.
- 08-07-2007, 07:46 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
This line of code is your problem:
[code]
tmp[][] = getFileCOntent(new File(drives["C:\\" + FOLDER_LIST + "\\"));
[\code]
You reinitialize it each time, a very quick solution would be just to use a vector;
But if you have to use an array, try indexing the values of the array using the for loop variable int i! Indexing into the array will make sure that it doesn't keep getting rid of previous stuff.Java Code:vector v; v.add(what ever);
i.e.
Java Code:tmp[j] = value etc
Similar Threads
-
array problem
By oceansdepth in forum New To JavaReplies: 3Last Post: 04-05-2008, 02:25 AM -
Array problem.. help needed please!
By SCS17 in forum New To JavaReplies: 3Last Post: 03-06-2008, 10:30 PM -
TextArea additable and uneditable (copy/past problem)
By qwerty55 in forum Advanced JavaReplies: 0Last Post: 01-19-2008, 11:41 PM -
array problem
By wats in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:08 AM -
array problem
By Albert in forum Advanced JavaReplies: 2Last Post: 07-01-2007, 01:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks