vmioutils.java

来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 56 行

JAVA
56
字号
/*
 * $Id: VMIOUtils.java,v 1.1 2003/11/25 11:41:56 epr Exp $
 */
package java.io;

/**
 * Helper class for connecting java.io to JNode.
 * 
 * @author epr
 */
public class VMIOUtils {

	/** The filesystem API of JNode */
	private static VMFileSystemAPI api;
	private static Object token;

	/**
	 * Gets the JNode FileSystemService instance.
	 * 
	 * @return
	 */
	/*
	 * protected static FileSystemService getFileSystemService() throws IOException { if (fss ==
	 * null) { try { fss = (FileSystemService)InitialNaming.lookup(FileSystemService.NAME); } catch
	 * (NameNotFoundException ex) { throw new IOException("Cannot lookup FileSystemService", ex); } }
	 * return fss;
	 */

	/**
	 * Gets the JNode FileSystemAPI.
	 * 
	 * @return
	 */
	protected static VMFileSystemAPI getAPI() 
	throws IOException {
		return api;
	}

	public static void setAPI(VMFileSystemAPI newApi, Object newToken) {
		if (api == null) {
			api = newApi;
			token = newToken;
		} else {
			throw new SecurityException("Cannot overwrite the API");
		}
	}

	public static void resetAPI(Object resetToken) {
		if (token == resetToken) {
			api = null;
		} else {
			throw new SecurityException("Cannot reset the API with a different token");
		}
	}
}

⌨️ 快捷键说明

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