url2Html : url에 해당하는 html 코드를 스트링 형태로 리턴
/**
* url에 해당하는 html 코드를 스트링 형태로 리턴한다.
*
* @param url
* @param encode
* @return
* @throws Exception
*/
public static String url2Html(String url, String encode) throws Exception {
URL urlObj = null;
BufferedReader in = null;
String line = null;
StringBuffer buff = new StringBuffer();
try {
if (encode == null || encode.length() == 0) {
encode = “UTF-8”;
}
urlObj = new URL(url);
in = new BufferedReader(new InputStreamReader(urlObj.openStream(), encode));
while ((line = in.readLine()) != null) {
buff.append(line);
}
} catch (Exception e) {
_logger.exception(e);
throw e;
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
} finally {
in = null;
}
}
return buff.toString();
}