Package jodd.io

Examples of jodd.io.FastByteArrayOutputStream.toByteArray()


    }
    size = 0;
    if (memoryThreshold > 0) {
      FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream(memoryThreshold + 1);
      int written = input.copyMax(fbaos, memoryThreshold + 1);
      data = fbaos.toByteArray();
      if (written <= memoryThreshold) {
        size = data.length;
        valid = true;
        return;
      }
View Full Code Here


      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

    FastByteArrayOutputStream out = size != -1 ?
        new FastByteArrayOutputStream(size) :
        new FastByteArrayOutputStream();

    writeToStream(out);
    return out.toByteArray();
  }

  /**
   * Saves attachment to a file.
   */
 
View Full Code Here

    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

      oos = new ObjectOutputStream(bos);
      oos.writeObject(obj);
    } finally {
      StreamUtil.close(oos);
    }
    return bos.toByteArray();
  }

  /**
   * De-serialize an object from byte array.
   */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.