> gaur.rit...@gmail.com wrote:
> > I am looking for a code to read sub directories that are created
[quoted text clipped - 4 lines]
>
> Arne
YA! Thats True, but I also need to delete the contents inside them.
Sample Code .......
------------------------
File f1 = new File ( "C:\\Systems01") ;
File[] strFilesDirs = f1.listFiles ( );
for ( int i = 0 ; i < strFilesDirs.length ; i ++ ) {
if ( strFilesDirs[i].isDirectory ( ) )
System.out.println ( "Directory: " + strFilesDirs[i] ) ;
else if ( strFilesDirs[i].isFile ( ) )
System.out.println ( "File: " + strFilesDirs[i] + " (" +
strFilesDirs[i].length ( ) + ")" ) ;
-------------------------------------------------
This is what I am using, the problem is to delete the particular
content from a sub directory.
Such As:
Systems01
---Alpha
-----Kilo
-------Temp
I need to delete the contents of the Temp Directory!
Alpha is a random name, but the inside structure is going to be same
(Kilo>Temp)
Christian - 02 Mar 2008 17:21 GMT
How about writting a method that recursivele deletes everything ..
maybe recursion would do the job?
Christian
Robert Klemme - 02 Mar 2008 17:45 GMT
>> gaur.rit...@gmail.com wrote:
>>> I am looking for a code to read sub directories that are created
[quoted text clipped - 35 lines]
> Alpha is a random name, but the inside structure is going to be same
> (Kilo>Temp)
Does it need to be a Java program? I'm asking because usually this can
be easily done by standard tools available on your operating system
("del" on windows or "rm -rf", "find ... | xargs rm" on Unixes).
Kind regards
robert
petersprc - 02 Mar 2008 19:10 GMT
Hi,
Here's the code:
http://www.rgagnon.com/javadetails/java-0483.html
Probably better than using Runtime.exec which would be less
portable...
> >> gaur.rit...@gmail.com wrote:
> >>> I am looking for a code to read sub directories that are created
[quoted text clipped - 43 lines]
>
> robert
Roedy Green - 03 Mar 2008 21:07 GMT
>YA! Thats True, but I also need to delete the contents inside them.
you mean wipe the file for security? When you delete the file the
sectors it occupies are put on the free space chain to be reused.
normally that is sufficient.
The CIA can recover data even if you wipe several times. See
http://mindprod.com/jgloss/wipe.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Arne Vajhøj - 17 Mar 2008 03:54 GMT
>> gaur.rit...@gmail.com wrote:
>>> I am looking for a code to read sub directories that are created
[quoted text clipped - 33 lines]
> Alpha is a random name, but the inside structure is going to be same
> (Kilo>Temp)
You can recurse through multiple levels of directories.
If you have an "order of delete" problem, then put the
to be deleted stuff in a collection in the correct order
and delete from that in the end.
Arne