All pastes #370764 Raw Edit

Someone

public java v1 · immutable
#370764 ·published 2007-02-24 21:09 UTC
rendered paste body
    private static boolean connect(String proxy, int port) {    	boolean working = false;        Socket proxySocket = null;        PrintWriter out = null;        BufferedReader in = null;               try {  	           proxySocket = new Socket(proxy, port);           out = new PrintWriter(proxySocket.getOutputStream(), true);           in = new BufferedReader(new InputStreamReader(                                    proxySocket.getInputStream()));                        out.println("GET http://u1.swirve.com/ HTTP/1.1 \n");                        String currentLine;            while((currentLine = in.readLine()) != null) {                if(currentLine.equals("HTTP/1.1 OK") || currentLine.equals("HTTP/1.0 OK")) {                    working = true;                }            }        } catch (IOException e) {            working = false;        } finally {    		try {    			out.close();    			in.close();    			proxySocket.close();    		} catch(IOException e) {}    	}        return working;    }