Listing a directory the Java way

List the contents of a directory with groovy using the built in methods of Java. The groovy way is described in the following snippetsList files of a specific type, List directory contents and list files recursively.
(more…)

Count lines

Howto count all lines from stdin or a file in groovy.
(more…)

List directory contents with AntBuilder

This shows how to list the content of a directory with AntBuilder.
(more…)

Run Groovy in AntBuilder

This is a nonsense example of how to run groovy code with the groovy task in AntBuilder.
(more…)

Logging with groovy

Logging with groovy is as simple as this.
(more…)

Creating a Zipfile with AntBuilder

This is an example of the groovy antbuilder to create a zipfile.
(more…)

Printf in groovy

This shows you how to use the printf function in groovy to print a tic tac toe field like this:

   | x | o
---+---+---
   | x |
---+---+---
 o |   |

in stdout

(more…)

Determine the size of a file

The lengt function prints out the size of a file.

(more…)

Create random integers in a specific range

For example you would like to create 10 pseudo random numbers between 0 and 10.
(more…)

Using Ant build.xml and Antbuilder

This show how to combine the Ant build.xml and the groovy AntBuilder.
(more…)