Created
April 21, 2016 07:27
-
-
Save genffy/e99ae6ee47e465803400184aacf6c85b to your computer and use it in GitHub Desktop.
rm file for deep path folder, such as npm in windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
public class DeleteFiles { | |
public static void deleteFiles( File file ){ | |
if( file.isDirectory() ){ | |
File[] files = file.listFiles(); | |
if( files.length == 0 ){ | |
file.delete(); | |
} else { | |
for( File f : files ){ | |
deleteFiles(f); | |
f.delete(); | |
} | |
} | |
} else { | |
file.delete(); | |
} | |
} | |
public static void main(String[] args) { | |
File file = new File("C:\\Users\\genff\\WorkSpace\\github\\react-photo-feed\\node_modules"); | |
deleteFiles(file); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment