Package jodd.io

Examples of jodd.io.FastByteArrayOutputStream.toByteArray()


        putFile(header.formFieldName, newFile);
      } else {
        // no file, therefore it is regular form parameter.
        FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
        input.copyAll(fbos);
        String value = encoding != null ? new String(fbos.toByteArray(), encoding) : new String(fbos.toByteArray());
        putParameter(header.formFieldName, value);
      }

      input.skipBytes(1);
      input.mark(1);
View Full Code Here


        putFile(header.formFieldName, newFile);
      } else {
        // no file, therefore it is regular form parameter.
        FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
        input.copyAll(fbos);
        String value = encoding != null ? new String(fbos.toByteArray(), encoding) : new String(fbos.toByteArray());
        putParameter(header.formFieldName, value);
      }

      input.skipBytes(1);
      input.mark(1);
View Full Code Here

    }
    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

    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

        putFile(header.formFieldName, newFile);
      } else {
        // no file, therefore it is regular form parameter.
        FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
        input.copyAll(fbos);
        String value = encoding != null ? new String(fbos.toByteArray(), encoding) : new String(fbos.toByteArray());
        putParameter(header.formFieldName, value);
      }

      input.skipBytes(1);
      input.mark(1);
View Full Code Here

        putFile(header.formFieldName, newFile);
      } else {
        // no file, therefore it is regular form parameter.
        FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
        input.copyAll(fbos);
        String value = encoding != null ? new String(fbos.toByteArray(), encoding) : new String(fbos.toByteArray());
        putParameter(header.formFieldName, value);
      }

      input.skipBytes(1);
      input.mark(1);
View Full Code Here

    if (boundaryOutput.size() == 0) {
      throw new IOException("Problems with parsing request: invalid boundary");
    }
    skipBytes(1);
    boundary = new byte[boundaryOutput.size() + 2];
    System.arraycopy(boundaryOutput.toByteArray(), 0, boundary, 2, boundary.length - 2);
    boundary[0] = '\r';
    boundary[1] = '\n';
    return boundary;
  }
View Full Code Here

        valid = false;
        input.skipToBoundary();
        return;
      }
    }
    data = out.toByteArray();
    size = data.length;
    valid = true;
  }

}
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.