Package jodd.io

Examples of jodd.io.FastByteArrayOutputStream


      String fileName = part.getFileName();
      String contentId = (part instanceof MimePart) ? ((MimePart)part).getContentID() : null;
      String mimeType = EmailUtil.extractMimeType(part.getContentType());

      InputStream is = (InputStream) content;
      FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream();
      StreamUtil.copy(is, fbaos);

      email.addAttachment(fileName, mimeType, contentId, fbaos.toByteArray());
    } else if (content instanceof MimeMessage) {
      MimeMessage mimeMessage = (MimeMessage) content;

      addAttachmentMessage(new ReceivedEmail(mimeMessage));
    }
View Full Code Here


  /**
   * Returns byte content of the attachment.
   */
  public byte[] toByteArray() {
    FastByteArrayOutputStream out = size != -1 ?
        new FastByteArrayOutputStream(size) :
        new FastByteArrayOutputStream();

    writeToStream(out);
    return out.toByteArray();
  }
View Full Code Here

  /**
   * Create object copy using serialization mechanism.
   */
  public static <T extends Serializable> T cloneViaSerialization(T obj) throws IOException, ClassNotFoundException {
    FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
    ObjectOutputStream out = null;
    ObjectInputStream in = null;
    Object objCopy = null;

    try {
      out = new ObjectOutputStream(bos);
      out.writeObject(obj);
      out.flush();

      byte[] bytes = bos.toByteArray();

      in = new ObjectInputStream(new ByteArrayInputStream(bytes));
      objCopy = in.readObject();
    } finally {
      StreamUtil.close(out);
View Full Code Here

  /**
   * Serialize an object to byte array.
   */
  public static byte[] objectToByteArray(Object obj) throws IOException {
    FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
    ObjectOutputStream oos = null;

    try {
      oos = new ObjectOutputStream(bos);
      oos.writeObject(obj);
    } finally {
      StreamUtil.close(oos);
    }
    return bos.toByteArray();
  }
View Full Code Here

public class FastByteArrayServletOutputStream extends ServletOutputStream {

  protected final FastByteArrayOutputStream wrapped;

  public FastByteArrayServletOutputStream() {
    wrapped = new FastByteArrayOutputStream();
  }
View Full Code Here

    String className = One.class.getCanonicalName();
    byte klazz[] = proxetta.builder(One.class).create();
    //FileUtil.writeBytes("d:\\OneClone.class", klazz);

    FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream();
//    PrintStream out = System.out;
    System.setOut(new PrintStream(fbaos));

    One one = (One) ClassLoaderUtil.defineClass((new StringBuilder()).append(className).append(JoddProxetta.invokeProxyClassNameSuffix).toString(), klazz).newInstance();
    assertEquals("one ctor!one ctor!", fbaos.toString());    // clone ctor calls super ctor,
    fbaos.reset();

    one.example1();
    assertEquals("REPLACED VIRTUAL! jodd.proxetta.inv.Two * one!173>overriden sub", fbaos.toString());
    fbaos.reset();

    one.example2();
    assertEquals("REPLACED STATIC! one * jodd/proxetta/inv/Two * example2 * void example2() * jodd.proxetta.inv.One * jodd.proxetta.inv.One$$Clonetou!15013static: 4", fbaos.toString());
    fbaos.reset();

    one.example3();
    assertEquals("state = REPLACED ctor!", fbaos.toString());
    fbaos.reset();

    assertEquals("jodd.proxetta.inv.One$$Clonetou", one.getClass().getName());
    assertTrue(one instanceof Serializable);

    Annotation[] anns = one.getClass().getAnnotations();
View Full Code Here

TOP

Related Classes of jodd.io.FastByteArrayOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.