public static void transformChar ( Reader self , Writer writer , @ ClosureParams ( value = SimpleType . class , options = "java.lang.String" ) Closure closure ) throws IOException { int c ; try { char [ ] chars = new char [ 1 ] ; while ( ( c = self . read ( ) ) != - 1 ) { chars [ 0 ] = ( char ) c ; writer . write ( ( String ) closure . call ( new String ( chars ) ) ) ; } writer . flush ( ) ; Writer temp2 = writer ; writer = null ; temp2 . close ( ) ; Reader temp1 = self ; self = null ; temp1 . close ( ) ; } finally { closeWithWarning ( self ) ; closeWithWarning ( writer ) ; } }
Transforms each character from this reader by passing it to the given closure . The Closure should return each transformed character which will be passed to the Writer . The reader and writer will be both be closed before this method returns .