using wget in java application
921614Mar 4 2012 — edited Mar 5 2012Hello.
I want use 'wget' command from my Java application
for 'wget' i created command as String type.
Here is it
-----
String url_str=wget --post-data "year=2009&month=08&day=01&time=0&profile=1&start=0&stop=1000&step=50&par=&format=0&vars=01&vars=02" http://testsite.com/cgi/script.cgi -O /home/user/test_wget.txt
-----
then i use it in exec method
-----
...
try{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(url_str);
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 e){
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( InterruptedException e ) {
e.printStackTrace();
}
-----
after running the file test_wget.txt hold
-----
Error
Wrong key: not alpha/numerical characters
-----
however, if i use my url_str from Linux command line
test_wget.txt is hold usefull data.
So, how working correct with wget from Java application?
Thanks for any replys