loadtext.java
字号:
package piy.action;
import piy.PIYAction;
import piy.FixedProperty;
import java.io.*;
/**
* Loads text from a file into a String object, then returns the string.
*
* @author David Vivash
* @version 1.0, 28/04/01
*/
public class LoadText implements PIYAction, Serializable {
private FixedProperty loadFrom = new FixedProperty(null, File.class);
public FixedProperty getLoadFrom() { return loadFrom; }
public void setLoadFrom(FixedProperty file) { loadFrom = file; }
public Class getReturnType() { return String.class; }
public Object execute() {
byte[] text = null;
try {
FileInputStream input = new FileInputStream((File)loadFrom.getActualValue());
input.read(text = new byte[input.available()]);
input.close();
} catch (Exception e) {
System.out.println("Couldn't load text file: " + loadFrom);
}
return new String(text);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -