org.apache.cxf.helpers.IOUtils.toString()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(192)

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

IOUtils.toString介绍

暂无

代码示例

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

  1. ds = new ByteDataSource(IOUtils.toString(src.getReader()).getBytes(StandardCharsets.UTF_8),
  2. ct);

代码示例来源:origin: apache/cxf

  1. public static String toString(final InputStream input, String charset) throws IOException {
  2. return toString(input, DEFAULT_BUFFER_SIZE, charset);
  3. }
  4. public static String toString(final InputStream input, int bufferSize)

代码示例来源:origin: apache/cxf

  1. public static String readStringFromStream(InputStream in)
  2. throws IOException {
  3. return toString(in);
  4. }

代码示例来源:origin: org.apache.cxf/cxf-core

  1. public static String toString(final InputStream input, int bufferSize, String charset)
  2. throws IOException {
  3. int avail = input.available();
  4. if (avail > bufferSize) {
  5. bufferSize = avail;
  6. }
  7. Reader reader = charset == null ? new InputStreamReader(input, UTF8_CHARSET)
  8. : new InputStreamReader(input, charset);
  9. return toString(reader, bufferSize);
  10. }

代码示例来源:origin: apache/cxf

  1. public static String toString(final InputStream input, int bufferSize, String charset)
  2. throws IOException {
  3. int avail = input.available();
  4. if (avail > bufferSize) {
  5. bufferSize = avail;
  6. }
  7. Reader reader = charset == null ? new InputStreamReader(input, UTF8_CHARSET)
  8. : new InputStreamReader(input, charset);
  9. return toString(reader, bufferSize);
  10. }

代码示例来源:origin: org.apache.cxf/cxf-api

  1. public static String toString(final InputStream input, int bufferSize, String charset)
  2. throws IOException {
  3. int avail = input.available();
  4. if (avail > bufferSize) {
  5. bufferSize = avail;
  6. }
  7. Reader reader = charset == null ? new InputStreamReader(input, UTF8_CHARSET)
  8. : new InputStreamReader(input, charset);
  9. return toString(reader, bufferSize);
  10. }

代码示例来源:origin: apache/cxf

  1. private String getStringFromInputStream(InputStream in) throws Exception {
  2. return IOUtils.toString(in);
  3. }
  4. }

代码示例来源:origin: apache/servicemix

  1. public void getPerson(int id) throws Exception{
  2. String url = PERSON_SERVICE_URL + "person/get/" + id;
  3. System.out.println("\n### GET PERSON WITH ID " + id + " FROM URL " + url);
  4. HttpURLConnection connection = connect(url);
  5. connection.setDoInput(true);
  6. InputStream stream = connection.getResponseCode() / 100 == 2 ?
  7. connection.getInputStream() : connection.getErrorStream();
  8. System.out.println("Status: " + connection.getResponseCode() + " " +
  9. connection.getResponseMessage());
  10. System.out.println(IOUtils.toString(stream));
  11. }

代码示例来源:origin: apache/cxf

  1. private String getStringFromInputStream(InputStream in) throws Exception {
  2. return IOUtils.toString(in);
  3. }
  4. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testSchema() throws Exception {
  3. URL url = new URL("http://localhost:" + PORT + "/service/TestService?wsdl");
  4. String s = IOUtils.toString(url.openStream());
  5. Assert.assertTrue(s, s.contains("application/octet-stream"));
  6. }

代码示例来源:origin: apache/cxf

  1. private Document loadWsdl(String serviceName) throws Exception {
  2. HttpURLConnection connection = getHttpConnection("http://localhost:" + PORT + "/" + serviceName
  3. + "?wsdl");
  4. InputStream is = connection.getInputStream();
  5. String wsdlContents = IOUtils.toString(is);
  6. // System.out.println(wsdlContents);
  7. return StaxUtils.read(new StringReader(wsdlContents));
  8. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testImportSchema() throws Exception {
  3. String schemaURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?xsd=sayhi/sayhi/sayhi-schema1.xsd";
  4. URL url = new URL(schemaURL);
  5. try (InputStream ins = url.openStream()) {
  6. String output = IOUtils.toString(ins);
  7. assertTrue(output.indexOf("sayHiArray") > -1);
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. fail("Can not access the import schema");
  11. }
  12. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testImportWsdl() throws Exception {
  3. String wsdlURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?wsdl=sayhi/sayhi/a.wsdl";
  4. URL url = new URL(wsdlURL);
  5. try (InputStream ins = url.openStream()) {
  6. String output = IOUtils.toString(ins);
  7. assertTrue(output.indexOf("sayHiArray") > -1);
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. fail("Can not access the import wsdl");
  11. }
  12. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testImportWsdl2() throws Exception {
  3. String wsdlURL = "http://localhost:" + PORT + "/schemaimport/sayHi2" + "?wsdl=../sayhi/sayhi/a.wsdl";
  4. URL url = new URL(wsdlURL);
  5. try (InputStream ins = url.openStream()) {
  6. String output = IOUtils.toString(ins);
  7. assertTrue(output.indexOf("sayHiArray") > -1);
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. fail("Can not access the import wsdl");
  11. }
  12. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testSchemaInclude() throws Exception {
  3. String schemaURL = "http://localhost:" + PORT + "/schemainclude/service?xsd=d1/d1/test.xsd";
  4. URL url = new URL(schemaURL);
  5. try (InputStream ins = url.openStream()) {
  6. String output = IOUtils.toString(ins);
  7. assertTrue(output.indexOf("msg:RequestType") > -1);
  8. assertTrue(output.indexOf("msg:SomeFeatureType") > -1);
  9. } catch (Exception e) {
  10. e.printStackTrace();
  11. fail("Can not access the include schema");
  12. }
  13. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testAnotherSchemaImportl() throws Exception {
  3. String schemaURL = "http://localhost:" + PORT + "/schemaimport/service" + "?xsd=schema1.xsd";
  4. URL url = new URL(schemaURL);
  5. try (InputStream ins = url.openStream()) {
  6. String output = IOUtils.toString(ins);
  7. assertTrue(output.indexOf("schemaimport/service?xsd=schema2.xsd") > -1);
  8. assertTrue(output.indexOf("schemaimport/service?xsd=schema5.xsd") > -1);
  9. } catch (Exception e) {
  10. e.printStackTrace();
  11. fail("Can not access the import wsdl");
  12. }
  13. }

代码示例来源:origin: apache/cxf

  1. private String readUrl(String address) {
  2. String content = null;
  3. try {
  4. URL url = new URL(address);
  5. assertNotNull(url.getContent());
  6. content = IOUtils.toString((InputStream) url.getContent());
  7. } catch (IOException e) {
  8. e.printStackTrace(System.err);
  9. Assert.fail("Couldn't read URL: " + e.getMessage());
  10. }
  11. return content;
  12. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testGetBookQueryGZIP() throws Exception {
  3. String address = "http://localhost:" + PORT + "/bookstore/";
  4. WebClient wc = WebClient.create(address);
  5. wc.acceptEncoding("gzip,deflate");
  6. wc.encoding("gzip");
  7. InputStream r = wc.get(InputStream.class);
  8. assertNotNull(r);
  9. GZIPInputStream in = new GZIPInputStream(r);
  10. String s = IOUtils.toString(in);
  11. in.close();
  12. assertTrue(s, s.contains("id>124"));
  13. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testJaxWsMtomReply() throws Exception {
  3. setupForTest(true);
  4. DataHandlerBean dhBean = jaxwsClient.produceDataHandlerBean();
  5. Assert.assertNotNull(dhBean);
  6. String result = IOUtils.toString(dhBean.getDataHandler().getInputStream(), "utf-8");
  7. Assert.assertEquals(MtomTestImpl.STRING_DATA, result);
  8. }

代码示例来源:origin: apache/cxf

  1. @Test
  2. public void testMtomReply() throws Exception {
  3. setupForTest(true);
  4. DataHandlerBean dhBean = client.produceDataHandlerBean();
  5. Assert.assertNotNull(dhBean);
  6. String result = IOUtils.toString(dhBean.getDataHandler().getInputStream(), "utf-8");
  7. Assert.assertEquals(MtomTestImpl.STRING_DATA, result);
  8. }

相关文章