ついにgroovyにもsprintfが

+
+    /**
+     * Sprintf to a string.  Only works with JDK1.5 or later.
+     */
+    public static String sprintf(Object self, String format, Object[] values) {
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        PrintStream out = new PrintStream(outputStream);
+        printf(out, format, values);
+        return outputStream.toString();
+    }
+
+    void testSprintf() {
+        if (System.properties.'java.version'[2] >= '5') {
+            assert sprintf('%5.2f', 12 * 3.5) == '42.00'
+            assert sprintf('%d + %d = %d' , [1, 2, 1+2] as Integer[]) == '1 + 2 = 3'
+            assert sprintf('%d + %d = %d' , [3, 4, 3+4] as int[]) == '3 + 4 = 7'
+        }
+    }


printfがJDK1.6.0で動かないバグも直っている。