/ Published in: Java
An example that shows how to download files with wget from a Java program calling an external process. The key is read the output of process from the ErrorStream and not the InputStream.
Expand |
Embed | Plain Text
public class DLTest { try { ArrayList<String> adUrlList = new ArrayList<String>(); String line; while ( (line = adUrlReader.readLine()) != null ) { adUrlList.add( line.trim() ); } adUrlReader.close(); int fileCounter = 0; try { p.waitFor(); String s; while ((s = r.readLine())!=null) { } r.close(); fileCounter++; } } }
You need to login to post a comment.
