Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-07-2007, 05:43 AM
Member
 
Join Date: Jul 2007
Posts: 39
coco is on a distinguished road
Problem with array Copy
Please check this:

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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 09:46 AM
Member
 
Join Date: Jul 2007
Posts: 40
toby is on a distinguished road
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;
Code:
vector v; v.add(what ever);
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.

i.e.

Code:
tmp[j] = value etc
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
array problem oceansdepth New To Java 3 04-05-2008 04:25 AM
Array problem.. help needed please! SCS17 New To Java 3 03-07-2008 12:30 AM
TextArea additable and uneditable (copy/past problem) qwerty55 Advanced Java 0 01-20-2008 01:41 AM
array problem wats New To Java 1 12-12-2007 09:08 AM
array problem Albert Advanced Java 2 07-01-2007 03:13 AM


All times are GMT +3. The time now is 11:19 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org