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

📄 newioexample5.java

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

public class NewIOExample5
{
	public static void main(String args[])
	{
		char c[] = {'a', 'b', 'c', 'd', 'e'};
		CharBuffer b1 = CharBuffer.allocate(10);
		
		b1.put(c);	
		b1.flip();
		b1.position(2);
		CharBuffer b2 = b1.asReadOnlyBuffer();
		b2.position(3);
		print(b1);
		print(b2);
		
		b1.put(1, 'x');
		b2.put(2, 'y');
	}
	
	public static void print(Buffer b)
	{
		System.out.println("Position: "+b.position());
		System.out.println("   Limit: "+b.limit());
		System.out.println("Capacity: "+b.capacity());
	}
}

⌨️ 快捷键说明

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