⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesizetask.java

📁 这个范例程序演示了利用j2me技术开发无线服务器支持的应用。这是一个电影票订购程序
💻 JAVA
字号:
/*
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -