Java download file from internet without name in link?

LORD_RIDDL

New Member
How can i download file from internet, when it don't has a direct URL? Main question - Where can i take name and extension for file?For example when URL = "defaultSite.com/topic/9772.png" we can take last part of string and create file "9772.png", where we save stream of bytes.But from URL like:http://www.skype.com/go/getskypehttps://www.dropbox.com/download?plat=winwe can't take file name, however byte stream we can save with no problem. So how can i download file like that?upd:MIME can't help, i think, becouse file can have specific (user created) extension, or it return to me application/octet-stream even for .exe file. Besides problem whit file name left.upd2:Yes, server return headers, but it may be without file name. There from skype example:\[code\]conn.getHeaderField 0 : HTTP/1.1 200 OKconn.getHeaderField 1 : nginxconn.getHeaderField 2 : application/octet-streamconn.getHeaderField 3 : 30619240conn.getHeaderField 4 : Thu, 28 Feb 2013 19:35:47 GMTconn.getHeaderField 5 : bytesconn.getHeaderField 6 : max-age=86400conn.getHeaderField 7 : Thu, 04 Apr 2013 14:52:26 GMTconn.getHeaderField 8 : keep-aliveconn.getHeaderField 9 : S\[/code\]I need a reliable way to get name and extension.
 
Back
Top