📄 newioexample1.java
字号:
import java.nio.*;
public class NewIOExample1
{
public static void main(String args[])
{
char c[] = {'a', 'b', 'c', 'd', 'e'};
CharBuffer b = CharBuffer.allocate(10);
System.out.println("Before put data...");
print(b);
b.put(c);
System.out.println("Afert put data...");
print(b);
System.out.println("Before flip get data at position 7");
System.out.println("Read '"+b.get(7)+"'");
print(b);
System.out.println("After flip");
b.flip();
print(b);
System.out.println("Get data at position 7");
System.out.println("Read '"+b.get(7)+"'");
}
public static void print(Buffer b)
{
System.out.println("\tPosition: "+b.position());
System.out.println("\t Limit: "+b.limit());
System.out.println("\tCapacity: "+b.capacity());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -