public class DLTest { public static void main( String[] args ) { try { BufferedReader adUrlReader = new BufferedReader( new FileReader( "./AdUrls.csv" ) ); ArrayList<String> adUrlList = new ArrayList<String>(); String line; while ( (line = adUrlReader.readLine()) != null ) { adUrlList.add( line.trim() ); } adUrlReader.close(); int fileCounter = 0; for ( String adUrl : adUrlList ) { try { String cmdString = "/usr/bin/wget -v --output-document=/home/diggler/Desktop/groovy_testing/data_scrapes/Admonitor/DL/file" + Integer.to/ String(fileCounter) + " --tries=3 " + adUrl; System.out.println( cmdString ); Runtime rt = Runtime.getRuntime(); Process p = rt.exec( cmdString ); p.waitFor(); BufferedReader r = new BufferedReader(new InputStreamReader(p.getErrorStream())); String s; while ((s = r.readLine())!=null) { System.out.println( s ); } r.close(); } catch ( IOException ioe ) { ioe.printStackTrace(); } catch ( InterruptedException ie ) { ie.printStackTrace(); } fileCounter++; } } catch ( IOException e ) { e.printStackTrace(); } } }
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/10401.html