/** * 获得最终访问地址 * * @param link * @return */ public String getRealLink(String link) { try { HttpContext httpContext = new BasicHttpContext(); HttpUtil.get(link, "iso-8859-1", httpContext); RedirectLocations redirectLocations = (RedirectLocations) httpContext .getAttribute(DefaultRedirectStrategy.REDIRECT_LOCATIONS); if (redirectLocations != null) { ListuriList = redirectLocations.getAll(); URI uri = uriList.get(uriList.size() - 1); link = uri.toString(); } } catch (Exception e) { return link; } return link; }