Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting files over a week old

Status
Not open for further replies.

cobweb

IS-IT--Management
May 5, 2002
95
GB
Hi there:
I am trying to write an app that identifies files in a specific directory over a week old, then deleting them.
However, I am even stuck on the first part - the File class.
Am I right that the following should return a list of all files in the directory "B2delete"?
public static void main(String[] args) {
File dir = new File("c:/B2delete");
String[] allfiles = dir.list();
System.out.println(allfiles);

If not, can anybody tell me where I am going wrong?

Thanks!
 
Well, this is the JBuilder forum and your question is a pure Java one. Post these type of questions in forum269.

I think your code will simply print out an 'object reference' for the allFiles instance.

Try somthing like :-
Code:
int iStrings = allfiles.length;
for ( int i=0; i < iStrings; i++ ){
  System.out.println( allfiles[i] );
}

in place of your existing printing line.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top