0
我從應用程序運行時得到以下異常,但是當我作爲獨立運行時,我得到了其餘的調用響應位置幫助我解決了這個問題。服務器重定向太多次
java.net.ProtocolException:服務器重定向次數過多(20)
public static void main(String args[]) throws Exception{
String input = new String();
Authenticator.setDefault(new MyAuthenticator());
StringBuffer url = new StringBuffer();
url.append("https://rest-call-server-URL");
URL page;
try {
page = new URL(url.toString());
URLConnection conn = (URLConnection) page.openConnection();
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
input+=inputLine;
System.out.println(inputLine);
}
in.close();
// out.close();
//parseXmlList(input);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}