public static void write(Writer out,Object object) throws IOException {
  if (object instanceof String) {
    out.write((String)object);
  }
 else   if (object instanceof Object[]) {
    out.write(toArrayString((Object[])object));
  }
 else   if (object instanceof Map) {
    out.write(toMapString((Map)object));
  }
 else   if (object instanceof Collection) {
    out.write(toListString((Collection)object));
  }
 else   if (object instanceof Writable) {
    Writable writable=(Writable)object;
    writable.writeTo(out);
  }
 else   if (object instanceof InputStream || object instanceof Reader) {
    Reader reader;
    if (object instanceof InputStream) {
      reader=new InputStreamReader((InputStream)object);
    }
 else {
      reader=(Reader)object;
    }
    char[] chars=new char[8192];
    int i;
    while ((i=reader.read(chars)) != -1) {
      out.write(chars,0,i);
    }
    reader.close();
  }
 else {
    out.write(toString(object));
  }
}

public static void write ( Writer out , Object object ) throws IOException { if ( object instanceof String ) { out . write ( ( String ) object ) ; } else if ( object instanceof Object [ ] ) { out . write ( toArrayString ( ( Object [ ] ) object ) ) ; } else if ( object instanceof Map ) { out . write ( toMapString ( ( Map ) object ) ) ; } else if ( object instanceof Collection ) { out . write ( toListString ( ( Collection ) object ) ) ; } else if ( object instanceof Writable ) { Writable writable = ( Writable ) object ; writable . writeTo ( out ) ; } else if ( object instanceof InputStream || object instanceof Reader ) { Reader reader ; if ( object instanceof InputStream ) { reader = new InputStreamReader ( ( InputStream ) object ) ; } else { reader = ( Reader ) object ; } char [ ] chars = new char [ 8192 ] ; int i ; while ( ( i = reader . read ( chars ) ) != - 1 ) { out . write ( chars , 0 , i ) ; } reader . close ( ) ; } else { out . write ( toString ( object ) ) ; } }
writes an object to a writer using groovy ' s default representation for the object .
