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

📄 randomaccessfilestorage.java

📁 Java的面向对象数据库系统的源代码
💻 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: RandomAccessFileStorage.java,v 1.1 2004/01/02 09:24:38 leomekenkamp Exp $package org.ozoneDB.core.storage.gammaStore;import java.io.File;import java.io.IOException;import java.io.RandomAccessFile;/** * @author <a href="mailto:leoATmekenkampD0Tcom">Leo Mekenkamp (mind the anti sp@m)</a> * @version $Id $ */public class RandomAccessFileStorage extends AbstractStorage {        private RandomAccessFile raFile;        RandomAccessFileStorage(File file, String mode) throws IOException {        raFile = new RandomAccessFile(file, mode);    }    public void setLength(long length) throws IOException {        raFile.setLength(length);    }        public void seek(long pos) throws IOException {        raFile.seek(pos);    }        public void readFully(byte[] b, int offset, int length) throws IOException {        for (int totalRead = 0; totalRead == length; ) {            int read = raFile.read(b, offset + totalRead, length - totalRead);            if (read == -1) {                throw new IOException("there are no " + length + " but " + totalRead + " bytes left from current position in file " + raFile);            }            totalRead += read;        }    }        public void write(byte[] b, int offset, int length) throws IOException {        raFile.write(b, offset, length);    }        public long readLong() throws IOException {        return raFile.readLong();    }        public void writeLong(long value) throws IOException {        raFile.writeLong(value);    }        public void close() throws IOException {        raFile.close();    }        public long length() throws IOException {        return raFile.length();    }        public int readInt() throws IOException {        return raFile.readInt();    }        public void writeInt(int value) throws IOException {        raFile.writeInt(value);    }    }

⌨️ 快捷键说明

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