Due to the restrictive plugin handling at wordpress.com, I move the blog to my own server.
Thanks for the fish !
December 24, 2009
Blog moves House
December 23, 2009
Create XML file with MarkupBuilder
The most simple way to create XML content in the standard output or file.
def fw = new FileWriter("/somepath/persons.xml" )
// to write to standard out, remove fw
def xml = new groovy.xml.MarkupBuilder(fw)
xml.content() {
xml.parameter(x:0)
xml.person(id:100){
firstname("John")
lastname("Long")
}
xml.person(id:101){
firstname("Ken")
lastname("Smith")
}
}
Result
<content> <parameter x='0' /> <person id='100'> <firstname>John</firstname> <lastname>Long</lastname> </person> <person id='101'> <firstname>Ken</firstname> <lastname>Smith</lastname> </person> </content>
Please note the difference between MarkupBuilder and StramingMarkupBuilder. More information about XML processing at groovy.codehaus.org
MarkupBuilder is not very flexible, but simple to use for some basic task. If you require comments, XML declarations and more, your rather use the StreamingMarkupBuilder.
December 22, 2009
December 16, 2009
December 15, 2009
Groovy: Start from the Scratch
You have nothing but an installed Ubuntu Box, a JDK and no other clue ?
- Download the latest stable Groovy release from groovy.codehaus.org
- Unzip the file (maybe to your home folder) and keep the release name, like groovy-1.6.7
- Modify your .bashrc (gedit ~/.bashrc), usually you need to add this:
### GROOVY export GROOVY_HOME=/home/whateveryourusername/groovy-1.6.7 export PATH=$PATH:$GROOVY_HOME/bin
- Open a new shell and type groovy -version and you should get something like this:
Groovy Version: 1.6.7 JVM: 1.6.0_16 - Start the console with groovyConsole
- You are ready, lets get rolling with some snippets.
0.upto(2) { println “$it Hello World” }
Just started this blog to collect some Groovy Code Snippets, Tutorials, Links and News about Groovy (and Grails and anything nearby). Some stuff might appear ridiculous simple or “Hello Wirld” level, but no one force you to read this.
By the time I get started here Groovy 1.6.7 and Grails are the release versions.
I use Ubuntu 9.10, the GroovyConsole or Netbeans and Eclipse.
Dont ask for completeness, correctness or in-time feedback.
My main blog you find at javadude.wordpress.com
