private static void print(OutputStream stream, Object object) { if (object == null) { printBytes(stream, "(null)".getBytes()); } else if (object instanceof Iterable) { printIterable(stream, (Iterable) object); } else if (object instanceof Throwable) { printThrowable(stream, (Throwable) object); } else if (object.getClass().isArray()) { Object[] array = toObjectArray(object); printArray(stream, array); } else { printBytes(stream, object.toString().getBytes()); } }
private static void printArray(OutputStream stream, Object[] array) { List<Object> list = Arrays.asList(array); printIterable(stream, list); }