Java Download file from url with download dialog -


i want download file url shows html, displays download dialog after 2-3 seconds. if this:

     try {             url url = new url("http://my.url");             httpurlconnection con = (httpurlconnection) url.openconnection();              con.setrequestproperty("connection", "keep-alive");             con.setrequestproperty("content-length",                     integer.tostring(integer.max_value));             con.setreadtimeout(integer.max_value);             con.setconnecttimeout(integer.max_value);             con.connect();              bis = new bufferedinputstream(con.getinputstream(), 4096);              bytearray = ioutils.tobytearray(bis);              fileutils.writebytearraytofile(new file("myfile"), bytearray);           } catch (exception e) {         } 

i save displayed .html rather file displayed in save dialog. how should change code in order this?

i'm guessing dialog has javascript waits couple seconds , requests file download embedded in dialog somewhere.

if case, if figure out element 'real download' contained in, can use jsoup, or other html parser library scrape link out of page.

you have if download link generated dynamically.

after doing rossa suggests, i'd suggest setting javascript breakpoints in dialog window figure out how real url getting requested.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -