Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using wget in java application

921614Mar 4 2012 — edited Mar 5 2012
Hello.
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 2 2012
Added on Mar 4 2012
1 comment
1,482 views