filesizetask.java
来自「值得一看的J2ME_J2EE结合使用经典例程」· Java 代码 · 共 47 行
JAVA
47 行
/* * Copyright 2001 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. */package ant;import java.io.*;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.Task;/** * Simple task set a property to the size of a file. * It has two attributes, the file name and * the property name. The property set to the empty string * if the file does not exist. */public class FileSizeTask extends Task { File file; String property; // The method executing the task public void execute() throws BuildException { if (property != null && property.length() > 0) { if (file.exists()) { int size = (int)file.length(); project.setProperty(property, Integer.toString(size)); } else { project.setProperty(property, ""); } } } // The setter for the "message" attribute public void setFile(File file) { this.file = file; } // The setter for the "property" attribute public void setProperty(String prop) { property = prop; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?