In fact, Java use httpurlconnection download, will automatically under the load-directed file, but we do not know the target file of the real filename, file type, the following method can get the real URL, the following is an example of a Youku video.
Importjava.net.HttpURLConnection;ImportJava.net.URL;Importjava.util.ArrayList; Public classTest2 { Public Static voidMain (string[] args)throwsException {String str= "Http://f.youku.com/player/getFlvPath/sid/130258503437697_01/st/flv/fileid/ 03000201004da277e47ac503e2c7936b543e15-dfed-ee85-31e0-869a7be2f5b8? K=457eb55affadc5c5161b9af9&hd=0 "; URL URL=NewURL (str); HttpURLConnection Conn=(HttpURLConnection) url.openconnection (); Conn.getresponsecode (); String Realurl=Conn.geturl (). toString (); Conn.disconnect (); System.out.println ("Real URL:" +Realurl); }}
Java gets the real URL of the network redirection file