java nio 之FileChannel
来源:互联网 发布:魔术蜘蛛软件2.0 编辑:程序博客网 时间:2024/05/24 01:17
package com.nio;import java.io.FileNotFoundException;import java.io.IOException;import java.io.RandomAccessFile;import java.nio.ByteBuffer;import java.nio.channels.FileChannel;public class FileChannelTest{ public static void main(String[] args) throws FileNotFoundException { RandomAccessFile randomAccessFile=new RandomAccessFile("/home/plcm/test.txt", "rw"); FileChannel fileChannel=randomAccessFile.getChannel(); ByteBuffer buffer=ByteBuffer.allocate(1024); try { int byteReaded=fileChannel.read(buffer); while (byteReaded!=-1) { System.out.println("Read " + byteReaded); buffer.flip(); while (buffer.hasRemaining()) { System.out.println((char)buffer.get()); } buffer.clear(); byteReaded=fileChannel.read(buffer); } fileChannel.close(); } catch (IOException e) { // TODO implement catch IOException throw new UnsupportedOperationException("Unexpected Exception", e); } }}
Read 25aaaaaabbbbbcccccddddd
aaaaaabbbbbcccccddddd
0 0
- JAVA NIO之FileChannel
- Java nio 之 FileChannel
- java nio 之FileChannel
- java NIO 之fileChannel
- Java的NIO之FileChannel
- Java NIO之FileChannel学习
- Java - NIO之Channel(FileChannel)
- 8.Java NIO系列教程之FileChannel
- NIO之FileChannel
- Java NIO FileChannel
- Java NIO(8-FileChannel)
- Java NIO FileChannel
- Java NIO FileChannel
- java nio(二)FileChannel
- Java NIO -- FileChannel
- Java NIO (七) FileChannel
- Java NIO FileChannel
- Java NIO FileChannel
- 两种方法扫二维码下载APP,获取IPA安装包
- 关于如何禁止删除SharedPreference的一个尝试
- 数据库操作 mysql
- 时钟信号 SIGALRM ,signal()函数 ,setitimer()函数,pause()函数应用
- 为什么不能再where语句中使用聚合函数
- java nio 之FileChannel
- 【Matlab】连接字符串的方法
- Entity Framework Code First数据库连接
- 省市区三级联动
- signal 信号列表 (kill -l)
- vc++ bmp图像二值化
- 理解常量指针和指针常量
- php 下载文件,考虑到各种格式,解决下载时部分出现文件损坏的问题
- 【机器学习实战02】使用k-近邻算法改进约会网站的配对效果