bluesmore 2014-08-23
package com.test; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Calendar; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; public class Android { public static void main(String[] args) { try { DefaultHttpClient client = new DefaultHttpClient(); Calendar calendar = Calendar.getInstance(); while (true) { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); String date = format.format(calendar.getTime()); String url = "http://dl.google.com/android/adt/adt-bundle-mac-x86_64-" + date + ".zip"; HttpGet get = new HttpGet(url); HttpResponse response = client.execute(get); int status = response.getStatusLine().getStatusCode(); System.err.println(url); System.err.println(status); if(status==200){ break; } get.abort(); calendar.add(Calendar.DAY_OF_MONTH, -1); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }