Archive for the ‘Groovy’ category

Dyncon 2011

February 27th, 2011

In about two weeks I’m going to Dyncon 2011, a conference for dynamic languages and frameworks. There will be talks about Erlang, Node.js, Clojure, Python and ofcourse Groovy & Grails. I’m proud to be one of the speakers and I’m going to talk about Groovy & Grails. During my talk, I will build a Google TV like web application. This I will show how powerfull Groovy & Grails is!!

So if you have a change to come to Stockholm, join us at Dyncon! It will be a very exciting and interesting weekend.

Groovy Code Sample

February 21st, 2010

For my latest project ProboGen, I needed the functionality to create and zip files. I found this this groovy code and show its show how powerfull groovy is.

File.metaClass.zip = { String destination ->
   def result = new ZipOutputStream(new FileOutputStream(destination))
    result.withStream {zipOutStream->
     delegate.eachFileRecurse { f ->
           if(!f.isDirectory()) {
              zipOutStream.putNextEntry(new ZipEntry(f.getPath()))
              new FileInputStream(f).withStream { inStream ->
                    def buffer = new byte[1024]
                    def count
                     while((count = inStream.read(buffer, 0, 1024)) != -1) {
                                zipOutStream.write(buffer)
                     }
              }
              zipOutStream.closeEntry()
            }
         }
        }
    }

To zip up a directory you can now just say:


new File("/data/ft/").zip("/ft.zip");

This is really neat solution.

Thanks to : powerful groovy