ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steffen Schluff" <>
Subject AW: echoing filesize
Date Wed, 30 Jul 2003 11:39:26 GMT
Hello David,

Sun once had such a task shipped with one of its MIDP examples. I pasted it
below including the respective ant settings. Once you got the jar file size
just use a token to put it in the jad file.


 * Copyright 2001 by Sun Microsystems, Inc.,
 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
 * All rights reserved.
package ant;



 * 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;



Best wishes,

Steffen Schluff
Orientation in Objects GmbH

-----Ursprungliche Nachricht-----
Von: dc []
Gesendet: Mittwoch, 30. Juli 2003 12:57
An: 'Ant Users List'
Betreff: echoing filesize

Is there a built in ant task that can echo a filesize?
can task output be directed to a variable?

I am trying to create a portable build env that doesn't require external


<property name="filesize" value="... somehow read a file's size" />

<echo file="${MIDlet-Name}.jad" append="false">
	MIDlet-Name: ${MIDlet-Name}


david [dc] collier

Web & Mobile Contents Business Group

  e   |
  v   |  +81(0)90 7414 6107

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message