/** * Write the specified <code>Body</code> to the specified * <code>OutputStream</code>. * * @param body * the <code>Body</code> to write. * @param out * the OutputStream to write to. * @throws IOException * if an I/O error occurs. */ public void writeBody(Body body, OutputStream out) throws IOException { if (body instanceof Message) { writeEntity((Message) body, out); } else if (body instanceof Multipart) { writeMultipart((Multipart) body, out); } else if (body instanceof SingleBody) { ((SingleBody) body).writeTo(out); } else throw new IllegalArgumentException("Unsupported body class"); }