使用java.net.URLConnection,在特定URL上使用GET,此特定URL将重定向到新页面。如何从响应中获取新URL?
答案 0 :(得分:0)
鉴于Rishal的链接和amobiz的回答是我正在寻找的:
URLConnection con = new URL( url ).openConnection();
System.out.println( "orignal url: " + con.getURL() );
con.connect();
System.out.println( "connected url: " + con.getURL() );
InputStream is = con.getInputStream();
System.out.println( "redirected url: " + con.getURL() );
is.close();