Utils.java 741 Bytes
package com.lil.om;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Utils {
	public String wget(String urlToGet) {
		// Simple class that gets a URL and returns the contents as as string
		StringBuffer sb = new StringBuffer();
		try {
			URL url = new URL(urlToGet);
	        URLConnection yc = url.openConnection();
	        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
	        String inputLine;
	        while ((inputLine = in.readLine()) != null) 
	            sb.append(inputLine);
	        in.close();
		} catch (Exception e) {
			return e.getMessage();
		}
		return sb.toString();
	}
}