本文整理汇总了Java中javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.TEXT_PLAIN_TYPE属性的具体用法?Java MediaType.TEXT_PLAIN_TYPE怎么用?Java MediaType.TEXT_PLAIN_TYPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.ws.rs.core.MediaType
的用法示例。
在下文中一共展示了MediaType.TEXT_PLAIN_TYPE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFormPostResponse
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)) {
multiPart.getBodyParts().add(filePart);
return target(endpoint).request().post(
Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE));
}
}
示例2: findResponseType
@SuppressWarnings("rawtypes")
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;
}