savetext.java

来自「PIY(Program It Yourself)是一个基于Java的应用程序开发」· Java 代码 · 共 37 行

JAVA
37
字号
package piy.action;

import piy.PIYAction;
import piy.FixedProperty;
import java.io.*;

/**
* Saves text to a specified file.
*
* @author David Vivash
* @version 1.0, 02/05/01
*/
public class SaveText implements PIYAction, Serializable {
	private FixedProperty saveTo = new FixedProperty(null, File.class);
	private FixedProperty toSave = new FixedProperty("", String.class);

	public FixedProperty getTo() { return saveTo; }
	public void setTo(FixedProperty file) { saveTo = file; }

	public FixedProperty getSave() { return toSave; }
	public void setSave(FixedProperty text) { toSave = text; }

	public Class getReturnType() { return null; }
	
	public Object execute() {		
		try {
			FileOutputStream output = new FileOutputStream((File)saveTo.getActualValue());
			output.write(((String)toSave.getActualValue()).getBytes());
			output.close();	
		} catch (Exception e) {
			System.out.println("Couldn't load text file: " + saveTo);
		}

		return null;
	}

}

⌨️ 快捷键说明

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