Groovy: An elegant JVM-based language
Being a Java developer for so many years, having programmed in Python recently and now having a look at Groovy, I am sure every Java developer must have a look at this elegant JVM-based language.
I have just started going through Groovy and I am feeling like programming in Java in a simpler way.
Take a look at how is easy to get a content from an url.
def url = new URL("http://ichart.finance.yahoo.com/table.csv?s=PETR4.SA")
url.eachLine { line ->
println line.split(",")
}
In this example I got a csv file from an url and did a split in each line of the file.
What about working with dates and locales?
import static java.text.DateFormat.*
import static java.util.Locale.*
def today = new Date()
[ENGLISH, ITALY, FRANCE, GERMAN].each { loc ->
println getDateInstance(FULL, loc).format(today)
}
Will print:
Tuesday, January 5, 2010
martedì 5 gennaio 2010
mardi 5 janvier 2010
Dienstag, 5. Januar 2010
Simple and elegant, isn’t it?
Much more at groovy website.
See you!
Advertisement




