openstreamtest.java

来自「java编程开发技巧与实例的编译测试通过的所有例程」· Java 代码 · 共 29 行

JAVA
29
字号
import java.net.*;
import java.io.*;

public class OpenStreamTest
{
	public static void main(String args[])
	{
		try
		{
			URL yahoo	=	new URL("http://www.google.com/");
			DataInputStream dis = new DataInputStream(yahoo.openStream());
			String inputLine;
			while	((inputLine = dis.readLine()) != null)
			{
				System.out.println(inputLine);
			}
			dis.close();
		}
		catch	(MalformedURLException me)
		{
			System.out.println("MalformedURLException: " + me);
		}
		catch	(IOException ioe)
		{
			System.out.println("IOException: " + ioe);
		}
	}
}

⌨️ 快捷键说明

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