Skip to content

Instantly share code, notes, and snippets.

/listFiles.java Secret

Created April 12, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1af73f2254f839f58690a6e7e3dc9c5e to your computer and use it in GitHub Desktop.
Save anonymous/1af73f2254f839f58690a6e7e3dc9c5e to your computer and use it in GitHub Desktop.
list files using Process hangs
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