📄 channelmanager.java
字号:
/* * Created on Nov 19, 2004 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */package com.nay0648.ds.bplustree;import java.io.*;import java.nio.channels.*;/** * * @author nay0648 * * this is used to manage file channle.all file operation to the B+ tree * get the file channel by this class */class ChannelManager{private static final String FILE_OPEN_MODE="rw";//open tree file in rw modeprivate String path; /** * @param path the tree file path */ public ChannelManager(String path) { this.path=path; } /** * get a new channel of the tree file * @return return null if field */ public FileChannel getChannel() { FileChannel ch=null; try { ch=(new RandomAccessFile(path,FILE_OPEN_MODE)).getChannel(); } catch(IOException exc) { exc.printStackTrace(); } return ch; } /** * recycle a channel * @param ch the channel of the tree file */ public void recycle(Channel ch) { try { if(ch.isOpen()) ch.close(); } catch(IOException exc) { exc.printStackTrace(); } } /* public static void main(String[] args) {} */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -