查看南京地铁各个站点间的距离
import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class HttpConnection { public static void main(String[] args) throws Exception { final String startStation="56";//起点站 final String endStation="33";//终点站 new Thread(new Runnable() { @Override public void run() { try { URLConnection connection= new URL("http://www.njmetro.com.cn/PageAjax/SelectTickPrice.ashx?oneSite="+startStation+"&twoSite="+endStation).openConnection(); InputStream inStream= connection.getInputStream(); byte [] buff=new byte[1024]; int len=-1; while((len=inStream.read(buff))!=-1){ try { Thread.sleep(10); System.out.println(new String(buff,0,len)); } catch (InterruptedException e) { System.out.println(new String(buff,0,len)); } } } catch (IOException e) { e.printStackTrace(); } } }).start(); } }