01: package com.technoetic.xplanner.util;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05: import java.net.URL;
06: import java.net.URLConnection;
07:
08: public class HttpClient {
09: public String getPage(String urlString) throws IOException {
10: URL url = new URL(urlString);
11: URLConnection connection = url.openConnection();
12: connection.connect();
13: InputStream stream = connection.getInputStream();
14: byte[] readBuffer = new byte[256];
15: StringBuffer page = new StringBuffer();
16: int pos = stream.read(readBuffer, 0, 255);
17: while (pos > 0) {
18: page.append(new String(readBuffer, 0, pos));
19: pos = stream.read(readBuffer, 0, 255);
20: }
21: return page.toString();
22: }
23: }
|