System.out.println(list1[i].lastModified());
prints a mili second string, didnt see how to format it.
1083077609416
Date d = new Date(modTime);
System.out.println(d.toString());
Fri Aug 10 14:41:29 EDT 2007
EDIT: seems to work now... do you see any issues that I might not?
EDIT: Changed package and file name.
EDIT: Seems to run into a issue.
Optional, I can figure error handeling out later. How can I capture this error and display something useful... like line the problem is on?
I just need to know why right now, is it something I am forgetting?
Exception in thread "main" java.lang.NullPointerException
at listIt.ListIt.getList(ListIt.java:18)
at listIt.ListIt.<init>(ListIt.java:12)
at listIt.ListIt.getList(ListIt.java:24)
at listIt.ListIt.<init>(ListIt.java:12)
at listIt.ListIt.main(ListIt.java:35)
Sorry I keep bugging you, you are helping me alot here. I keep playing as I can which is why you see the EDITs to keep current steps. I change the code to be the latest and error to follow just to make sure you understand. I am decent at understanding code I just lack overall knowlege and expierence I guess. Once I am done with this thing I will buy a book and try to learn more on my own. In the mean time thanks for the help. I have stayed true to my original request and just trying to get the final result. If you see me break any coding rules please let me know so I learn that part as well, I want others to be able to read it. You Rock!
package listIt;
import java.io.File;
import java.util.Date;
public class ListIt
{
public ListIt(String folder)
{
File File = new File(folder);
this.getList(File);
}
private void getList(File folder)
{
File[] list1 = folder.listFiles();
for (int i = 0; i < list1.length; i++)
{
long modTime = list1[i].lastModified();
Date d = new Date(modTime);
if (list1[i].isDirectory())
{
ListIt list2 = new ListIt(list1[i].toString());
System.out.println(list1[i] + "\\\t" + d.toString());
}
else
System.out.println(list1[i].toString() + "\t" + d.toString());
}
}
public static void main(String[] args)
{
//ListIt myListIt = new ListIt("C:\\Documents and Settings\\");
ListIt myListIt = new ListIt("C:\\");
}
}