http://www.cafeaulait.org/slides/sd2000east/webclient/Web_Client_Programming_with_Java.html
看看对楼主有没有帮助。

解决方案 »

  1.   

    用Jlabel.setText()将你的代码放进去
      

  2.   

    public static String getText(String uriStr) {
            final StringBuffer buf = new StringBuffer(1000);
        
            try {
                // Create an HTML document that appends all text to buf
                HTMLDocument doc = new HTMLDocument() {
                    public HTMLEditorKit.ParserCallback getReader(int pos) {
                        return new HTMLEditorKit.ParserCallback() {
                            // This method is whenever text is encountered in the HTML file
                            public void handleText(char[] data, int pos) {
                                buf.append(data);
                                buf.append('\n');
                            }
                        };
                    }
                };
        
                // Create a reader on the HTML content
                URL url = new URI(uriStr).toURL();
                URLConnection conn = url.openConnection();
                Reader rd = new InputStreamReader(conn.getInputStream());
        
                // Parse the HTML
                EditorKit kit = new HTMLEditorKit();
                kit.read(rd, doc, 0);
            } catch (MalformedURLException e) {
            } catch (URISyntaxException e) {
            } catch (BadLocationException e) {
            } catch (IOException e) {
            }
        
            // Return the text
            return buf.toString();
        }