📄 delete.java
字号:
package jmathlib.toolbox.io;
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
import java.io.*;
public class delete extends ExternalFunction
{
public OperandToken evaluate(Token[] operands)
{
if (getNArgIn(operands) != 1)
throwMathLibException("delete: number of arguments != 1");
if (!(operands[0] instanceof CharToken))
throwMathLibException("delte: argument must be a string");
String name = ((CharToken)operands[0]).toString();
File file = null;
try
{
file = new File(getWorkingDirectory(),name);
}
catch (Exception e)
{
throwMathLibException("delete: exception");
}
if (!file.delete())
throwMathLibException("delete: did not work");
return null;
} // end eval
}
/*
@GROUP
IO
@SYNTAX
delete(filename)
@DOC
delete a file
@EXAMPLES
<programlisting>
delete("bar.txt");
</programlisting>
@SEE
cd, createnewfile, dir, exist, mkdir, rmdir, isfile, isdirectory, ishidden, lastmodified
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -