Write XML with GroovyBuilder

By dave

Groovy supports the concept of builders, which provide an abstraction between the required output content and the representation of it. Groovy supports this by providing a tree like structure in groovy code that represents the required HTML or XML: So what have we done? We generated some HTML, in this case we just printed it to the console, but we could...

Reading XML in groovy using XmlParser

By dave

Groovy has great inbuilt xml support, and allows you to treat xml paths like objects. Reading elements and attributes is so straightforward that it was one of the factors that got me started with Groovy. So to build an object tree from xml, we just use the class. To dereference an element we use normal dot syntax, for an attribute,...

Generate an ATOM feed with GroovyBuilder

By dave

Lastly, we look at building an ATOM document using the same principles. ATOM provides a means for site owners to provide updates to site users. It works by providing an XML document showing recent changes to the site. Browsers that support RSS and RSS readers can then highlight these changes to users. An atom formatted document contains two main sections, the...

Introduction to GSQL (Groovy SQL)

By dave

In this article I cover working with SQL from Groovy using the GSQL support built into the language. This is not a complete guide, rather a getting started guide, that shows you a few of the concepts. Firstly, GSQL is built on top of JDBC; which you are probably already familiar with. If not there are many good web guides and...

Using thread local in Java

By dave

This article assumes that you are already familiar with concurrent programming and design. Java 1.5 introduced the concurrent library , which provides an extensive set of classes for dealing with concurrency issues, these sit alongside some existing classes that have been around since earlier times. I've noticed that some of the classes I mention here don't get used as often as...

Reading a GZIP file using Java

By dave

Another common compression file format on Linux is the GZIP format. Java again has out of the box support for this file format. Gzip files differ from zip files in that they only contain one file, the compressed form of the original file with a .gz extension. Java's takes such a file type and decompresses it. We can treat ...

Formatting numbers using NumberFormat

By dave

is the class used to convert numeric values such as int, long and double into Strings. It has been around since the early days of Java, and generally performs well. Especially if you cache an instance of the class for repeated use. IMHO the only down side to using is that it can look a little verbose. To get...

Reading a zip file from java using ZipInputStream

By dave

Java provides support for reading zip files in the form of . This class provides an API where you can iterate over all the items in a given zip file, reading the data from the archive for each file. In order to do this, first you must create the instance giving the file that you wish to expand. Then you...

Wrapping JFreeChart as a Groovy builder

By dave

Groovychart is a library hosted on Java.net that wraps the functionality available in JFreeChart for use as a groovy builder. Currently it is available in snapshot form but hopefully time permitting, a full build will follow soon. I really like groovy as a scripting language, it's great for writing simple UI's for displaying graphical data from many sources including XML and...

These may be of interest

We use cookies to analyse traffic and to personalise content. We also embed Twitter and Youtube on some pages, these companies have their own privacy policies.

See the privacy policy and terms of use of this site should you need more information or wish to adjust your settings.