📄 datareader.java
字号:
package dms.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class DataReader {
/**
* 把备份的日志文件映射为本地内存缓冲,便于后面解析
* @param fileName 备份日志文件名
* @return 日志文件在内存的映射缓冲
* @throws FileNotFoundException,IOException
* @throws IOException
*/
public MappedByteBuffer mappingLogBuffer(String fileName) throws FileNotFoundException,IOException {
MappedByteBuffer buffer = null;
FileChannel channel = null;
File file = new File(fileName);
FileInputStream fis = new FileInputStream(file);
channel = fis.getChannel();
buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
channel.close();
return buffer;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -