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

📄 arrayfile.java

📁 Nachos 5 java version
💻 JAVA
字号:
// PART OF THE MACHINE SIMULATION. DO NOT CHANGE.package nachos.machine;/** * A read-only <tt>OpenFile</tt> backed by a byte array. */public class ArrayFile extends OpenFileWithPosition {    /**     * Allocate a new <tt>ArrayFile</tt>.     *     * @param	array	the array backing this file.     */    public ArrayFile(byte[] array) {	this.array = array;    }    public int length() {	return array.length;    }    public void close() {	array = null;    }    public int read(int position, byte[] buf, int offset, int length) {	Lib.assert(offset >= 0 && length >= 0 && offset+length <= buf.length);		if (position < 0 || position >= array.length)	    return 0;	length = Math.min(length, array.length-position);	System.arraycopy(array, position, buf, offset, length);	return length;    }    public int write(int position, byte[] buf, int offset, int length) {	return 0;    }    private byte[] array;}

⌨️ 快捷键说明

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