Link to home
Start Free TrialLog in
Avatar of trowa
trowa

asked on

Delete nested folder in JSP?

How to delete a nested folder that contains files/sub folders in JSP?

thanks.
Avatar of mraible
mraible

Same way you would in java.

Look at java.io.File in the Javadocs.

http://java.sun.com/j2se/1.3/docs/api/java/io/File.html

You should be able to delete a file or directory with the "delete" method.
ASKER CERTIFIED SOLUTION
Avatar of cheekycj
cheekycj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trowa

ASKER

CJ, thanks again. The nuke function above work well, but it didn't delete the folder itself. Let's say:

i call nuke("\a");

all the sub-folder and files in a folder is deleted, but the a folder itself is not deleted.

Maybe you can show me how to delete the a folder also inside the Nuke function above.

and why when i compare a String value, i must use:

if (strvalue.equals("abc")) {
//
}

but not if (strvalue == "abc") {
//
}

?

Is this the syntax of Java? what's their difference?

Thanks :)
you can just after you call the nuke function do this:

nuke(path);
File dirToDelete = new File(path);
path.delete();

string1.equals(string2) or even
string1.equalsIgnoreCase(string2) are the way to compare strings in java b/c the String object has those methods implemented to compare the values whereas the "==" operator on Objects (Strings are Objects) compares if the two objects are pointing to the same memory reference.  Big Difference :-)

Here is a good link that explains this:
http://www.michael-thomas.com/java/javacert/JCP_ObjectEqual.htm

HTH,
CJ

Avatar of trowa

ASKER

Thanks a lot again, CJ :)
Glad I could help and Thanx for the "A".

CJ