web services - How to automate downloading a files using java program -


i need download files multiple links page (may more 100 files separate links) automatically. know url login , have credentials.

i'm willing in java program automation. way go downloading location page through login site.

is curl command helpful this?

please advise me this.

you can use wget can download log files:

wget -r --no-parent --user=user --password=password --no-check-certificate <url> 
  • you can pass headers in --header, e.g. --header "cookie: jsonsessionid=3433434343434"
  • you can pass post data using --post-data 'email=$email&password=$passwrd'

or can use following httpclient in java:

public void savefile(string url, string filename) throws clientprotocolexception, ioexception{             httpget httpget = new httpget(url);             httpresponse response = httpclient.execute(httpget);             httpentity entity = response.getentity();             if (entity != null) {                 long len = entity.getcontentlength();                 inputstream = entity.getcontent();                 fileoutputstream fos = new fileoutputstream(new file(filepath)));                 ioutils.copy(is, fos);             }             return;         } 

Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -