java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Ant arrow How to use Touch task
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4096
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Touch task E-mail
User Rating: / 2
PoorBest 

Touch

Description

Changes the modification time of a file and possibly creates it at the same time. In addition to working with a single file, this Task can also work a Fileset (which also includes directories) or a Filelist (since Ant 1.6).

Parameters

Attribute Description Required
file The name of the file. Unless a nested fileset element or a nested filelist element has been specified.
millis Specifies the new modification time of the file in milliseconds since midnight Jan 1 1970. No--datetime takes precedence, however if both are omitted the current time is assumed.
datetime Specifies the new modification time of the file.
pattern SimpleDateFormat-compatible pattern string. Defaults to MM/DD/YYYY HH:MM AM_or_PM or MM/DD/YYYY HH:MM:SS AM_or_PM. Since Ant 1.6.3 No
mkdirs Whether to create nonexistent parent directories when touching new files. Since Ant 1.6.3 No, default false.
verbose Whether to log the creation of new files. Since Ant 1.6.3 No, default true.

Parameters specified as nested elements

fileset

You can use any number of nested <fileset> elements to define the files for this task and refer to <fileset>s defined elsewhere.

filelist

Since Ant 1.6

You can use any number of nested <filelist> elements to define the files for this task and refer to <filelist>s defined elsewhere.

mapper

Since Ant 1.6.3, a nested mapper can be specified. Files specified via nested filesets, filelists, or the file attribute are mapped using the specified mapper. For each file mapped, the resulting files are touched. If the original file exists its timestamp will be used. Otherwise the task settings (millis, datetime) take effect.

Examples

  <touch file="myfile"/>

creates myfile if it doesn't exist and changes the modification time to the current time.

  <touch file="myfile" datetime="06/28/2000 2:02 pm"/>

creates myfile if it doesn't exist and changes the modification time to Jun, 28 2000 2:02 pm (14:02 for those used to 24 hour times).

  <touch datetime="09/10/1974 4:30 pm">
    <fileset dir="src_dir"/>
  </touch>

changes the modification time to Oct, 09 1974 4:30 pm of all files and directories found in src_dir.

  <touch file="myfile" datetime="06/28/2000 2:02:17 pm"/>

creates myfile if it doesn't exist and changes the modification time to Jun, 28 2000 2:02:17 pm (14:02:17 for those used to 24 hour times), if the filesystem allows a precision of one second - a time close to it otherwise.

  <touch file="foo">
    <mapper type="glob" from="foo" to="bar" />
  </touch>

creates bar if it doesn't exist and changes the modification time to that of foo.

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.