Java Code Examples for

The following are Jave code examples for showing how to use TEXT_PLAIN_TYPE of the class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: oryx2   File:   Source Code and License Vote up 7 votes
protected final Response getFormPostResponse(String data,
                                             String endpoint,
                                             Class<? extends OutputStream> compressingClass,
                                             String encoding) throws IOException {
  byte[] bytes;
  if (compressingClass == null) {
    bytes = data.getBytes(StandardCharsets.UTF_8);
  } else {
    bytes = compress(data, compressingClass);
  MediaType type =
      encoding == null ? MediaType.TEXT_PLAIN_TYPE : new MediaType("application", encoding);
  InputStream in = new ByteArrayInputStream(bytes);
  StreamDataBodyPart filePart = new StreamDataBodyPart("data", in, "data", type);
  try (MultiPart multiPart = new MultiPart(MediaType.MULTIPART_FORM_DATA_TYPE)) {
    return target(endpoint).request().post(
        Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE));
Example 2
Project: minijax   File:   Source Code and License Vote up 6 votes
private MediaType findResponseType(
        final Object obj,
        final List<MediaType> produces) {

    final Class<?> objType = obj == null ? null : obj.getClass();

    for (final MediaType mediaType : produces) {
        final MessageBodyWriter writer = providers.getMessageBodyWriter(objType, null, null, mediaType);
        if (writer != null) {
            return mediaType;

    return MediaType.TEXT_PLAIN_TYPE;