📄 textfromurl.java
字号:
/* * TextFromURL.java * * Created on October 4, 2002, 12:38 PM */package ch20;import java.net.*;import java.io.*;/** * * @author Stephen Potts */public class TextFromURL{ int rawData; /** Creates a new instance of TextFromURL */ public TextFromURL() { try { URL myURL = new URL("http://java.sun.com"); URLConnection uc = myURL.openConnection(); System.out.println("the host is " + myURL.getHost()); System.out.println("****************************"); System.out.println("Here is the HTML for this page"); InputStream is = myURL.openStream(); while((rawData = is.read()) != -1) { System.out.print((char)rawData); } is.close(); }catch (MalformedURLException mue) { System.out.println("Exception " + mue); }catch (Exception e) { System.out.println("Exception " + e); } } /** * @param args the command line arguments */ public static void main(String[] args) { TextFromURL tfu = new TextFromURL(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -