All pastes #370340 Raw Edit

Someone

public java v1 · immutable
#370340 ·published 2007-02-24 13:53 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")) {                    out.close();                    in.close();                    proxySocket.close();                                        working = true;                }            }            out.close();            in.close();            proxySocket.close();            return working;        }        catch (IOException e) {            return false;        }        finally {    		try {    			out.close();    			in.close();    			proxySocket.close();    		} catch(IOException e) {}    	}    }