private Optional<String> asString(TextBody textBody) throws IOException { return Optional.ofNullable(IOUtils.toString(textBody.getInputStream(), charset(Optional.ofNullable(textBody.getMimeCharset())))); }
/** Process body of message as plain text */ private void processTextBody(JCas jCas, TextBody textBody) throws IOException { String text = CharStreams.toString(textBody.getReader()); jCas.setDocumentText(text.trim()); }
public SingleBodyBuilder copy(final SingleBody other) throws IOException { if (other == null) { return this; } if (other instanceof TextBody) { String charsetName = ((TextBody) other).getMimeCharset(); if (charsetName != null) { try { this.charset = Charset.forName(charsetName); } catch (IllegalCharsetNameException ex) { throw new UnsupportedEncodingException(charsetName); } catch (UnsupportedCharsetException ex) { throw new UnsupportedEncodingException(charsetName); } } } this.bin = ContentUtil.buffer(other.getInputStream()); return this; }
/** * Sets body of this message. Also sets the content type based on properties of * the given {@link org.apache.james.mime4j.dom.Body}. * * @param body * the body. */ public AbstractEntityBuilder setBody(TextBody textBody) { this.body = textBody; if (textBody != null) { String mimeCharset = textBody.getMimeCharset(); if ("us-ascii".equalsIgnoreCase(mimeCharset)) { mimeCharset = null; } if (mimeCharset != null) { setField(Fields.contentType("text/plain", new NameValuePair("charset", mimeCharset))); } else { setField(Fields.contentType("text/plain")); } } else { removeFields(FieldName.CONTENT_TYPE); } return this; }
private Optional<String> asString(TextBody textBody) throws IOException { return Optional.ofNullable(IOUtils.toString(textBody.getInputStream(), charset(Optional.ofNullable(textBody.getMimeCharset())))); }
/** Process body of message as plain text */ private void processTextBody(JCas jCas, TextBody textBody) throws IOException { String text = CharStreams.toString(textBody.getReader()); jCas.setDocumentText(text.trim()); }
private Optional<String> asString(TextBody textBody) throws IOException { return Optional.ofNullable(IOUtils.toString(textBody.getInputStream(), charset(Optional.ofNullable(textBody.getMimeCharset())))); }
StringBuilder sb = new StringBuilder(); try { Reader r = body.getReader(); int c; while ((c = r.read()) != -1) {