Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Ant - determine file size

Thread view: 
Andrew Thompson - 16 Oct 2007 07:04 GMT
I would like to add the file size to a variety of JNLP
(XML) files that are generated by ant, as are the
(Jar) files themselves.

It confounds me that there seems to be no way in
ant, to retrieve the size of a file as an integer figure
of bytes.

Did I miss something?  Either that provides that
functionality, or in the way ant works/is supposed to
work (e.g. write a custom task).

(BTW - ideally I am after an X-plat way, but for my own
purposes, even something 'exec' for Win. XP will do..)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Gordon Beaton - 16 Oct 2007 13:37 GMT
> It confounds me that there seems to be no way in ant, to retrieve
> the size of a file as an integer figure of bytes.

I don't think it's a something often needed by a typical build.

> Did I miss something? Either that provides that functionality, or in
> the way ant works/is supposed to work (e.g. write a custom task).

I've never done this myself, but implementing a new task doesn't look
all that intimidating:

  <taskdef name="FileSize" classname="org.whatever.FileSize"/>

Then do something simple with java.io.File.length()?

/gordon

--
Andrew Thompson - 16 Oct 2007 13:56 GMT
>> It confounds me that there seems to be no way in ant, to retrieve
>> the size of a file as an integer figure of bytes.
>
>I don't think it's a something often needed by a typical build.

I was beginning to suspect that.  Daniel's pointer to
the introduction of it in 1.6.3 supports that even more,
in that it seems rather later to be introducing something
which is imperative for a good build tool.

>> Did I miss something? Either that provides that functionality, or in
>> the way ant works/is supposed to work (e.g. write a custom task).
>
>I've never done this myself, but implementing a new task doesn't look
>all that intimidating:

I had implemented a custom task for the saverbeans project.
As you suspect - it is not that tricky.  But another thing I
forgot to menion was that I wanted these build files (in the
best situation) to be available to anyone running Ant (1.n.n+),
and introducing custom tasks complicates that.

I think I'll go with Daniel's suggestion and 1.6.3+.

Thanks for the input.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Daniel Dyer - 16 Oct 2007 13:43 GMT
> I would like to add the file size to a variety of JNLP
> (XML) files that are generated by ant, as are the
[quoted text clipped - 10 lines]
> (BTW - ideally I am after an X-plat way, but for my own
> purposes, even something 'exec' for Win. XP will do..)

http://ant.apache.org/manual/CoreTasks/length.html

Since Ant 1.6.3.

Dan.

Signature

Daniel Dyer
http://www.uncommons.org

Andrew Thompson - 16 Oct 2007 13:57 GMT
(re Ant)
>> I would like to add the file size ...
..
>http://ant.apache.org/manual/CoreTasks/length.html
>
>Since Ant 1.6.3.

I'll have to upgrade, but that is just what I was after.
My build files are about to become 1.6.3+.   :-)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Andrew Thompson - 16 Oct 2007 14:00 GMT
>(re Ant)
>>> I would like to add the file size ...
[quoted text clipped - 5 lines]
>I'll have to upgrade, but that is just what I was after.
>My build files are about to become 1.6.3+.   :-)

Unhhh..

C:\Documents and Settings\Administrator>ant -version
Apache Ant version 1.7.0 compiled on December 13 2006

Looks like it is my *documentation* that needs 'upgrading'!

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.