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

📄 newioexample2.java

📁 JAVA SE6 全方位学习 朱仲杰 编著 机械工业出版社出版
💻 JAVA
字号:
import java.nio.*;

public class NewIOExample2
{
	public static void main(String args[])
	{
		char c[] = {'a', 'b', 'c', 'd', 'e'};
		ByteBuffer b = ByteBuffer.allocate(10);
		
		for (int i=0; i<c.length; i++)
			b.putChar(c[i]);
		b.flip();
		
		while(b.hasRemaining())
			System.out.print(b.get()+"\t");
		System.out.println();
		
		b.rewind();
		while(b.hasRemaining())
			System.out.print(b.getChar()+"\t");
		System.out.println();

		b.rewind();
		CharBuffer cb = b.asCharBuffer();
		while(cb.hasRemaining())
			System.out.print(cb.get()+"\t");
		System.out.println();
	}
}

⌨️ 快捷键说明

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