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

📄 socketchannelcreate.java

📁 java nio 编程一个实例子.服务端程序
💻 JAVA
字号:
package com.ronsoft.books.nio.channels;import java.net.*;import java.nio.channels.*;import java.io.IOException;/** * Test creation of SocketChannels. * Created and tested: Dec 31, 2001 * @author Ron Hitchens (ron@ronsoft.com) * @version $Id: SocketChannelCreate.java,v 1.1 2002/01/22 21:09:28 ron Exp $ */public class SocketChannelCreate{	public static void main (String [] argv)		throws IOException	{		SocketChannel sc;		Socket sock;		sc = SocketChannel.open();		sock = sc.socket();		print ("SocketChannel.open()", sc, sock);		sock = new Socket();		sc = sock.getChannel();		print ("SocketChannel.open()", sc, sock);	}	private static void print (String msg, SocketChannel sc, Socket sock)	{		boolean hasChannel = (sc != null);		boolean hasSocket = (sock != null);		System.out.println (msg + ": channel=" + hasChannel			+ ", socket=" + hasSocket);	}}

⌨️ 快捷键说明

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