📄 printurlpage.java
字号:
import java.net.*;import java.io.*;public class PrintURLPage{ // Default Constructor public PrintURLPage() { super(); } // Read the HTML page public void printHTMLPage( String urlStr ) { URL url = null; BufferedReader reader = null; String data = null; try { // Create the URL object url = new URL( urlStr ); // Decorate the input stream with something easier to use reader = new BufferedReader( new InputStreamReader(url.openStream()) ); // Keep reading lines until there are no more to read while( (data = reader.readLine()) != null ) { // Just write out the text to the console System.out.println( data ); } } catch( MalformedURLException ex ) { ex.printStackTrace(); } catch( IOException ex ) { ex.printStackTrace(); } } // Start the example public static void main( String args[] ) { if ( args.length == 0 ) { System.out.println( "Usage: java PrintURLPage http://<url>" ); System.exit( 0 ); } // Get the url passed in on the command line String url = args[0]; PrintURLPage f = new PrintURLPage(); // Get and print the url passed in f.printHTMLPage( url ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -