做了一些小重构
This commit is contained in:
parent
cea1ff78f7
commit
36166f5b60
|
@ -9,5 +9,8 @@
|
||||||
<module name="disaster_warning" />
|
<module name="disaster_warning" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="天气灾害预警" target="17" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -12,9 +12,9 @@ import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class WeatherDisasterWarningGrabber
|
public class WeatherDisasterWarningGrabber
|
||||||
{
|
{
|
||||||
private static String QUERY_URL = "https://devapi.qweather.com/v7/warning/now?";
|
private final static String QUERY_URL = "https://devapi.qweather.com/v7/warning/now?";
|
||||||
private static String USER_KEY = "fe9fa8eeeb6f4301a92541eed565dd15";
|
private final static String USER_KEY = "fe9fa8eeeb6f4301a92541eed565dd15";
|
||||||
private static QWeatherDisasterWarningItem item = null;
|
//private static QWeatherDisasterWarningItem item = null;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 从和风天气获取天气警报json字符串
|
* 从和风天气获取天气警报json字符串
|
||||||
|
@ -44,12 +44,10 @@ public class WeatherDisasterWarningGrabber
|
||||||
connection.setReadTimeout( 60000 );
|
connection.setReadTimeout( 60000 );
|
||||||
connection.connect();
|
connection.connect();
|
||||||
|
|
||||||
int reponseCode = connection.getResponseCode();
|
|
||||||
|
|
||||||
//如果responseCode为200,说明访问成功!
|
//如果responseCode为200,说明访问成功!
|
||||||
if ( connection.getResponseCode() == 200 )
|
if ( connection.getResponseCode() == 200 )
|
||||||
{
|
{
|
||||||
//注意,和风使用了gizp压缩响应体
|
//注意,和风使用了gzip压缩响应体
|
||||||
inputStream = new GZIPInputStream( connection.getInputStream() );
|
inputStream = new GZIPInputStream( connection.getInputStream() );
|
||||||
bufferedReader = new BufferedReader( new InputStreamReader( inputStream, "UTF-8" ) );
|
bufferedReader = new BufferedReader( new InputStreamReader( inputStream, "UTF-8" ) );
|
||||||
|
|
||||||
|
@ -100,6 +98,7 @@ public class WeatherDisasterWarningGrabber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert connection != null;
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue