cdcommand.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 35 行
JAVA
35 行
/*
* $Id: CdCommand.java,v 1.4 2004/01/27 20:52:52 epr Exp $
*/
package org.jnode.fs.command;
import java.io.File;
import org.jnode.shell.help.FileArgument;
import org.jnode.shell.help.Help;
import org.jnode.shell.help.Parameter;
import org.jnode.shell.help.ParsedArguments;
/**
* @author Ewout Prangsma (epr@users.sourceforge.net)
*/
public class CdCommand {
static final FileArgument ARG_DIR = new FileArgument("directory", "the directory to switch to");
public static Help.Info HELP_INFO = new Help.Info("cd", "Go to the given directory", new Parameter[] { new Parameter(ARG_DIR, Parameter.MANDATORY)});
public static void main(String[] args) throws Exception {
ParsedArguments cmdLine = HELP_INFO.parse(args);
final File dir = ARG_DIR.getFile(cmdLine);
if (dir.exists() && dir.isDirectory()) {
System.getProperties().setProperty("user.dir", dir.getAbsoluteFile().getCanonicalPath());
} else if("/".equals(dir.getCanonicalPath())) {
System.getProperties().setProperty("user.dir", "/");
} else {
System.err.println(dir + " is not a valid directory");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?