⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmlreaderbean.java

📁 卡内基梅隆大学软件工程课件,很全面
💻 JAVA
字号:
/* * * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. *  * This software is the proprietary information of Sun Microsystems, Inc.   * Use is subject to license terms. *  */import javax.naming.*;import javax.ejb.*;import java.net.*;import java.io.*;public class HTMLReaderBean implements SessionBean {   public StringBuffer getContents() throws HTTPResponseException {     Context context;     URL url;     StringBuffer buffer;     String line;     int responseCode;     HttpURLConnection connection;     InputStream input;     BufferedReader dataInput;      try {        context = new InitialContext();        url = (URL)context.lookup("java:comp/env/url/MyURL");          connection = (HttpURLConnection)url.openConnection();        responseCode = connection.getResponseCode();     } catch (Exception ex) {         throw new EJBException(ex.getMessage());     }     if (responseCode != HttpURLConnection.HTTP_OK) {        throw new HTTPResponseException("HTTP response code: " +            String.valueOf(responseCode));     }     try {        buffer = new StringBuffer();        input = connection.getInputStream();        dataInput = new BufferedReader(new InputStreamReader(input));        while ((line = dataInput.readLine()) != null) {           buffer.append(line);           buffer.append('\n');        }       } catch (Exception ex) {         throw new EJBException(ex.getMessage());     }     return buffer;  } // getContents()   public HTMLReaderBean() {}   public void ejbCreate() {}   public void ejbRemove() {}   public void ejbActivate() {}   public void ejbPassivate() {}   public void setSessionContext(SessionContext sc) {}} // HTMLReaderBean

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -