📄 newioexample3.java
字号:
import java.nio.*;
public class NewIOExample3
{
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.duplicate();
b2.position(3);
print(b1);
print(b2);
b1.put(1, 'x');
System.out.println("Data: "+b2.get(1));
}
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 + -