diff options
Diffstat (limited to 'src/java/com/juick/http/www/Utils.java')
-rw-r--r-- | src/java/com/juick/http/www/Utils.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/java/com/juick/http/www/Utils.java b/src/java/com/juick/http/www/Utils.java index 38550691..4c41555e 100644 --- a/src/java/com/juick/http/www/Utils.java +++ b/src/java/com/juick/http/www/Utils.java @@ -17,6 +17,10 @@ */ package com.juick.http.www; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -118,4 +122,20 @@ public class Utils { ret = ret.replaceAll("@", "\\\\@"); return ret; } + + public static String fetchURL(String url) { + try { + URLConnection c = new URL(url).openConnection(); + BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream())); + String inputLine; + StringBuilder b = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + b.append(inputLine).append("\n"); + } + in.close(); + return b.toString(); + } catch (Exception e) { + return null; + } + } } |