Hi. I am attempting to update a Jtable with details of all the files on my computer. I am running Windows XP home edition version 2002 with service pack 3. Intel(R) pentium(R) 4 CPU 3.20 GHz
for (int i = 0; i<r.size(); i++)
{
Vector v = new Vector();
{
String s;
long d = ((File)r.elementAt(i)).lastModified();
java.util.Date dat1 = new java.util.Date(d);
s = String.valueOf(dat1);
contents[i].getAbsolutePath());
v.addElement((String)((File)r.elementAt(i)).getName());
v.addElement((String.valueOf(((File)r.elementAt(i)).length())));
v.addElement((String)s);
v.addElement((String)((File)r.elementAt(i)).getAbsolutePath());
rows.addElement(v);
table.addNotify();
System.out.println(i);
}
}
Other code I have not published looks up all the files on my computer to put it in a JTree while this is happening I store all files the field Vector r. Then this loop updates the table rows. My problem is the program freezes. The reason I print i was to get printed confirmation that the loop is traversing the vector. The program has completed once and updated the table as it is supposed to; so in this respect I know it works. However, 9 of 10 times it freezes. I have only tested on 1 computer because well I only have 1. Could it be that I need a java update of some sort? Or perhaps just my computer? I suspect it is the Vector because initially I did this:
public void search()
{
File[] contents = path.listFiles();
try
{
for (int i = 0; i<contents.length; i++)
{
Vector v = new Vector();
if(contents[i] != null)
{
if (contents[i].isDirectory())
{
search(contents[i].getAbsolutePath(), find);
}
else
{
String s;
long d = contents[i].lastModified();
java.util.Date dat1 = new java.util.Date(d);
s = String.valueOf(dat1);
contents[i].getAbsolutePath());
v.addElement((String)contents[i].getName());
v.addElement((String.valueOf(contents[i].length())));
v.addElement((String)s);
v.addElement((String)contents[i].getAbsolutePath());
rows.addElement(v);
r.addElement(contents[i].getAbsolutePath());
table.addNotify();
}
}
}
}
catch(Exception e)
{
System.out.println("Following Exception occured - " + e);
}
}
This works 100% the first method works faster in theory because the vector has already filtered out directories so the loop is shorter.
Your help would be appreciated