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