-
-
Save anonymous/1af73f2254f839f58690a6e7e3dc9c5e to your computer and use it in GitHub Desktop.
list files using Process hangs
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.lang.*; | |
import java.util.*; | |
import java.io.*; | |
public class ListFiles { | |
private final static String unixBasePath = "/var/www/dev_swf_converter_rest_api/current/FILES"; | |
public static void main(String [] args) { | |
ArrayList<String> files = new ArrayList<String>(); | |
try { | |
Process p = Runtime.getRuntime().exec("find " + unixBasePath + " -type f"); | |
p.waitFor(); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
String fileName = null; | |
while( ( fileName = reader.readLine() ) != null ){ | |
System.out.println(fileName); | |
files.add(fileName); | |
} | |
} | |
catch(IOException ex){ | |
ex.printStackTrace(); | |
} | |
catch(InterruptedException ex){ | |
ex.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment