📄 filestreamstorage.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// Copyright (C) 2003-@year@, Leo Mekenkamp. All rights reserved.//// $Id: FileStreamStorage.java,v 1.1 2004/01/02 09:24:38 leomekenkamp Exp $package org.ozoneDB.core.storage.gammaStore;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.math.BigInteger;/** * @author <a href="mailto:leoATmekenkampD0Tcom">Leo Mekenkamp (mind the anti sp@m)</a> * @version $Id $ */public class FileStreamStorage extends AbstractStorage { private DataInputStream in = null; private DataOutputStream out = null; private File file; FileStreamStorage(File file) throws IOException { this.file = file; } private void checkForWrite() throws IOException { if (out == null) { out = new DataOutputStream(new FileOutputStream(file)); } } private void checkForRead() throws IOException { if (in == null) { in = new DataInputStream(new FileInputStream(file)); } } public void setLength(long length) throws IOException { throw new UnsupportedOperationException("not supported in FileStreamStorage"); } public void seek(long pos) throws IOException { throw new UnsupportedOperationException("not supported in FileStreamStorage"); } public void readFully(byte[] b, int offset, int length) throws IOException { checkForRead(); in.readFully(b, offset, length); } public void write(byte[] b, int offset, int length) throws IOException { checkForWrite(); out.write(b, offset, length); out.flush(); } public long readLong() throws IOException { checkForRead(); return in.readLong(); } public void writeLong(long value) throws IOException { checkForWrite(); out.writeLong(value); out.flush(); } public void close() throws IOException { try { if (in != null) { in.close(); } } finally { if (out != null) { out.close(); } } } public long length() throws IOException { return file.length(); } public int readInt() throws IOException { checkForRead(); return in.readInt(); } public void writeInt(int value) throws IOException { checkForWrite(); out.writeInt(value); out.flush(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -