import java.util.*; import java.io.*; import java.net.*; public class StreetRouterServer { public static void main(String[] args) throws MalformedURLException, IOException { try { GetRoute2("San Francisco", "CA", "San Diego", "CA"); } catch (Exception e) { System.err.println(e); } } public static void GetRoute2(String fromcity, String fromstate, String tocity, String tostate) throws MalformedURLException, IOException { URL url = new URL("http://www.mapquest.com/cgi-bin/mqtrip?OPC=-1&ADDR_ORIGIN=&CITY_ORIGIN="+fromcity.replace(' ', '+')+"&STATE_ORIGIN="+fromstate+"&DPC=-1&ADDR_DESTINATION=&CITY_DESTINATION="+tocity.replace(' ', '+')+"&STATE_DESTINATION="+tostate+"&quest_mode=trip&results_display_mode=text"); URLConnection connection=url.openConnection(); DataInputStream d = new DataInputStream(connection.getInputStream()); String directions="Directions from "+fromcity+", "+fromstate+" to "+tocity+", "+tostate+":"; String line = d.readLine(); String substring = ""; try { do { line = d.readLine(); if (line.indexOf(substring) != -1) directions=directions+"\n"+line.substring(line.indexOf(substring)+substring.length(),line.indexOf("