All pastes #370342 Raw Edit

Miscellany

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