on 06-19-2008 5:23 AM
hi expert
I have simple query .
I have created one simple application in that i have created the simple folder in j2ee server. i want to delete this folder and content of this folder throught dynpro.how to do ?.
any body tell me the code of this ?
reply
thanks & Regards
vijay yewale
Hi,
Try this code
File f=new File(<YourFoldr Name>);
if(f.isDirectory())
f.delete();
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Vijay,
You can delete a directory using the following code
new File( Path).delete();
But if the folder is not empty; the code will not work; go through the following code to delete the child.
// using recursive function call, the child files/dirs will get deleted
public boolean deleteDirectory( File path)
{
if( path.exists() )
{
File[] files = path.listFiles();
for(int i=0; i<files.length; i++)
{
if(files<i>.isDirectory())
{
deleteDirectory(files<i>);
}else{
files<i>.delete();
}
}
}
return( path.delete() );
}
Regards
Vinod V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Make use of the delete method from the file
API
boolean delete()
Deletes the file or directory denoted by this abstract pathname.
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.