package tax; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import shared.Shared; import shared.Timer; import shared.Tools; public class Query { /** For testing throughput */ public static void main(String[] args){ // sun.net.http.errorstream.enableBuffering=true; // System.setProperty("sun.net.http.errorstream.enableBuffering", "true"); // System.setProperty("http.errorstream.enableBuffering", "true"); ////// System.setProperty("", ""); // System.setProperty("http.keepAlive", "true"); // System.setProperty("http.maxConnections", "50"); //// System.setProperty("", ""); //// System.setProperty("", ""); // // System.out.println("sun.net.http.errorstream.enableBuffering="+System.getProperty("sun.net.http.errorstream.enableBuffering")); // System.out.println("sun.net.http.errorstream.timeout="+System.getProperty("sun.net.http.errorstream.timeout")); // System.out.println("sun.net.http.errorstream.bufferSize="+System.getProperty("sun.net.http.errorstream.bufferSize")); // System.out.println("http.keepAlive="+System.getProperty("http.keepAlive")); // System.out.println("http.maxConnections="+System.getProperty("http.maxConnections")); // System.out.println(System.getProperties()); // System.out.println("="+System.getProperty("")); // System.out.println("="+System.getProperty("")); // System.out.println("="+System.getProperty("")); String x=args[0]; int requests=(args.length>1 ? Integer.parseInt(args[1]) : 1); Timer t=new Timer(); Timer t2=new Timer(); Timer t3=new Timer(); // URL url=toUrl(x); for(int i=0; i-1){ next+=count; if(next>=buffer.length){ buffer=Arrays.copyOf(buffer, buffer.length*2); } count=is.read(buffer, next, buffer.length-next); } is.close(); //TODO: Why am I not closing this stream? return new String(buffer, 0, next); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } public static InputStream toStream(String x){ URL url=null; try { url = new URL(x); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return null; } try { InputStream is=url.openStream(); return is; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } // public static URL toUrl(String x){ // URL url=null; // try { // url = new URL(x); // } catch (MalformedURLException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } // // return url; // } // // public static URLConnection toUrlConnection(URL url, String x){ // URLConnection urlc=null; // // try { // urlc = url.openConnection(); // } catch (IOException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // return urlc; // } }