2017-07-18 36 views
0

我正在开发天气应用程序,并使用openweather API来获取天气数据。 出于测试目的,我拿来了API的数据,并试图在日志打印,但由于某些原因,它不工作,我不断收到此错误: Logs天气API不加载并且线程继续暂停

这是我的Java和XML文件:Code

回答

1

while循环将永远不会停止,因为你没有更新的data

data = isr.read();   // read and assign int to data 
while(data!=-1){    // not -1 
    result += (char) data; // add to result 
    isr.read();    // read next 
    // data field value will never be updated inside loop ,hence infinite loop 
    } 

值,以便改变

data = isr.read(); // read and assign char to data 
while(data!=-1){ 
    result += (char) data; 
    data = isr.read(); 
    // data value will never be changes inside loop , infinite loop 
    } 

Gist link for concise approach