play.libs.XML.fromInputStream()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中play.libs.XML.fromInputStream()方法的一些代码示例,展示了XML.fromInputStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XML.fromInputStream()方法的具体详情如下:
包路径:play.libs.XML
类名称:XML
方法名:fromInputStream

XML.fromInputStream介绍

[英]Parse an InputStream as DOM.
[中]

代码示例

代码示例来源:origin: com.typesafe.play/play_2.10

/**
 * Parse an XML string as DOM.
 */ 
public static Document fromString(String xml) {
  try {
    return fromInputStream(
      new ByteArrayInputStream(xml.getBytes("utf-8")),
      "utf-8"
    );
  } catch(UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.typesafe.play/play

/**
 * Parses an XML string as DOM.
 *
 * @param xml the input XML string
 * @return the parsed XML DOM root.
 */
public static Document fromString(String xml) {
  try {
    return fromInputStream(
        new ByteArrayInputStream(xml.getBytes("utf-8")),
        "utf-8"
    );
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * Parses an XML string as DOM.
 *
 * @param xml the input XML string
 * @return the parsed XML DOM root.
 */
public static Document fromString(String xml) {
  try {
    return fromInputStream(
        new ByteArrayInputStream(xml.getBytes("utf-8")),
        "utf-8"
    );
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * Parses an XML string as DOM.
 *
 * @param xml the input XML string
 * @return the parsed XML DOM root.
 */
public static Document fromString(String xml) {
  try {
    return fromInputStream(
        new ByteArrayInputStream(xml.getBytes("utf-8")),
        "utf-8"
    );
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.typesafe.play/play

@Override
  protected Document parse(Http.RequestHeader request, ByteString bytes) throws Exception {
    return XML.fromInputStream(bytes.iterator().asInputStream(), request.charset().orElse(null));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.12

@Override
  protected Document parse(Http.RequestHeader request, ByteString bytes) throws Exception {
    return XML.fromInputStream(bytes.iterator().asInputStream(), request.charset().orElse(null));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.11

@Override
  protected Document parse(Http.RequestHeader request, ByteString bytes) throws Exception {
    return XML.fromInputStream(bytes.iterator().asInputStream(), request.charset().orElse(null));
  }
}

代码示例来源:origin: play/play-java

/**
 * Get the response body as a {@link Document DOM document}
 * @return a DOM document
 */
public Document asXml() {
  try {
    return play.libs.XML.fromInputStream(ahcResponse.getResponseBodyAsStream(), "utf-8");
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.typesafe.play/play-java-ws

/**
 * Get the response body as a {@link Document DOM document}
 *
 * @return a DOM document
 */
@Override
public Document asXml() {
  String contentType = contentType();
  Charset charset = HttpUtils.parseCharset(contentType);
  if (charset == null) {
    charset = StandardCharsets.UTF_8;
  }
  return play.libs.XML.fromInputStream(ahcResponse.getResponseBodyAsStream(), charset.name());
}

相关文章