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

📄 filechannelexample5.java

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

public class FileChannelExample5
{
	public static void main(String args[]) throws Exception
	{
		FileInputStream fin = new FileInputStream("data1.txt");
		ByteBuffer b[] = new ByteBuffer[2];
		b[0] = ByteBuffer.allocate(10);
		b[1] = ByteBuffer.allocate(10);
		FileChannel fc = fin.getChannel();
		fc.read(b);
		fc.close();
		
		b[0].flip();
		b[1].flip();
	    while(b[0].hasRemaining())
			System.out.println("b[0]: "+b[0].getChar());
		while(b[1].hasRemaining())
			System.out.println("b[1]: "+b[1].getChar());
	}
}

⌨️ 快捷键说明

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