| Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML | ||||
|
||||
|
|
||||
| Tutorial Categories: Ajax
| Articles
| JSP
| Bioinformatics
| Database
| Free
Books |
Hibernate
| J2EE
| J2ME
| Java
| JavaScript
| JDBC
| JMS
| Linux
| MS
Technology |
PHP
| RMI
| Web-Services
| Servlets
| Struts
| UML
|
|
||||||||||||||||||||||||||||||
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||||||||||||||||||||||||||||||
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2007. All rights reserved.
Current Comments
1 comments so far (post your own) View All Comments Latest 10 Comments:you have done many erros in it..
1..>if the file will writeprotected then it will not delete by this programme..
2..>and ofcurese it will delete only single directory or file if directory content subdirectoris then it will not delete it ..as u knw
3>>>look at my code it will all subdirectes n files
but yaa there is an error in code find it actually it is not deleting files find n tell me why..
..................................
import java.io.*;
import java.util.*;
public class DeleteAny
{
public static void main(String args[])throws IOException
{
File f[]=new File[args.length];
for(int i=0; i<f.length; i++)
{
f[i]=new File(args[i]);
delete(f[i]);
}
}
static void delete(File f)
{try{System.out.println(";;"+f.getName()+" "+f.listFiles().length);
if(f.listFiles().length>1)
{
File fd[]=f.listFiles();
for(int i=0; i<fd.length; i++)
delete(fd[i]);
}
if(f.listFiles().length<1)
{ if(!f.canWrite())
{
if(f.isDirectory()|f.isFile())
f.delete();
}
}
}
catch(Exception e)
{
System.out.println("FILE NOT FOUND");
e.printStackTrace();
}
}
}
Posted by ankur on Sunday, 12.9.07 @ 20:16pm | #41665