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

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

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

IOUtils.newStringFromBytes介绍

[英]Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
[中]使用此函数而不是新字符串(字节[]),以避免非标准默认编码带来的意外。

代码示例

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

  1. public String toString() {
  2. return IOUtils.newStringFromBytes(buf, 0, count);
  3. }
  4. };

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

  1. public String toString() {
  2. return IOUtils.newStringFromBytes(buf, 0, count);
  3. }

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

  1. public String toString() {
  2. return IOUtils.newStringFromBytes(buf, 0, count);
  3. }

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

  1. /**
  2. * Use this function instead of new String(byte[], int, int)
  3. * to avoid surprises from non-standard default encodings.
  4. * @param bytes
  5. * @param start
  6. * @param length
  7. */
  8. public static String newStringFromBytes(byte[] bytes, int start, int length) {
  9. return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
  10. }

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

  1. /**
  2. * Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
  3. * @param bytes
  4. * @return
  5. */
  6. public static String newStringFromBytes(byte[] bytes) {
  7. return newStringFromBytes(bytes, UTF8_CHARSET.name());
  8. }

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

  1. /**
  2. * Use this function instead of new String(byte[], int, int)
  3. * to avoid surprises from non-standard default encodings.
  4. * @param bytes
  5. * @param start
  6. * @param length
  7. * @return
  8. */
  9. public static String newStringFromBytes(byte[] bytes, int start, int length) {
  10. return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
  11. }

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

  1. /**
  2. * Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
  3. * @param bytes
  4. */
  5. public static String newStringFromBytes(byte[] bytes) {
  6. return newStringFromBytes(bytes, UTF8_CHARSET.name());
  7. }

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

  1. /**
  2. * Use this function instead of new String(byte[], int, int)
  3. * to avoid surprises from non-standard default encodings.
  4. * @param bytes
  5. * @param start
  6. * @param length
  7. */
  8. public static String newStringFromBytes(byte[] bytes, int start, int length) {
  9. return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
  10. }

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

  1. /**
  2. * Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
  3. * @param bytes
  4. */
  5. public static String newStringFromBytes(byte[] bytes) {
  6. return newStringFromBytes(bytes, UTF8_CHARSET.name());
  7. }

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

  1. /**
  2. * Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
  3. * @param bytes
  4. */
  5. public static String newStringFromBytes(byte[] bytes) {
  6. return newStringFromBytes(bytes, UTF8_CHARSET.name());
  7. }

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

  1. /**
  2. * Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
  3. * @param bytes
  4. */
  5. public static String newStringFromBytes(byte[] bytes) {
  6. return newStringFromBytes(bytes, UTF8_CHARSET.name());
  7. }

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

  1. /**
  2. * Use this function instead of new String(byte[], int, int)
  3. * to avoid surprises from non-standard default encodings.
  4. * @param bytes
  5. * @param start
  6. * @param length
  7. */
  8. public static String newStringFromBytes(byte[] bytes, int start, int length) {
  9. return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
  10. }

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

  1. /**
  2. * Use this function instead of new String(byte[], int, int)
  3. * to avoid surprises from non-standard default encodings.
  4. * @param bytes
  5. * @param start
  6. * @param length
  7. */
  8. public static String newStringFromBytes(byte[] bytes, int start, int length) {
  9. return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
  10. }

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

  1. protected boolean equals(byte[] x, byte[] y) {
  2. String xx = IOUtils.newStringFromBytes(x);
  3. String yy = IOUtils.newStringFromBytes(y);
  4. return xx.equals(yy);
  5. }

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

  1. private String findBoundaryFromInputStream() throws IOException {
  2. InputStream is = message.getContent(InputStream.class);
  3. //boundary should definitely be in the first 2K;
  4. PushbackInputStream in = new PushbackInputStream(is, 4096);
  5. byte buf[] = new byte[2048];
  6. int i = in.read(buf);
  7. String msg = IOUtils.newStringFromBytes(buf, 0, i);
  8. in.unread(buf, 0, i);
  9. // Reset the input stream since we'll need it again later
  10. message.setContent(InputStream.class, in);
  11. // Use regex to get the boundary and return null if it's not found
  12. Matcher m = INPUT_STREAM_BOUNDARY_PATTERN.matcher(msg);
  13. return m.find() ? "--" + m.group(1) : null;
  14. }

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

  1. public void echoData(Holder<String> text, Holder<DataHandler> data) {
  2. try {
  3. InputStream bis = null;
  4. bis = data.value.getDataSource().getInputStream();
  5. byte[] b = new byte[6];
  6. bis.read(b, 0, 6);
  7. String string = IOUtils.newStringFromBytes(b);
  8. ByteArrayDataSource source =
  9. new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
  10. data.value = new DataHandler(source);
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

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

  1. public void echoData(Holder<String> text, Holder<DataHandler> data) {
  2. try {
  3. InputStream bis = null;
  4. bis = data.value.getDataSource().getInputStream();
  5. byte[] b = new byte[6];
  6. bis.read(b, 0, 6);
  7. String string = IOUtils.newStringFromBytes(b);
  8. ByteArrayDataSource source =
  9. new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
  10. data.value = new DataHandler(source);
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

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

  1. public void echoDataRef(Holder<DataStruct> data) {
  2. try {
  3. InputStream bis = null;
  4. bis = data.value.getDataRef().getDataSource().getInputStream();
  5. byte[] b = new byte[6];
  6. bis.read(b, 0, 6);
  7. String string = IOUtils.newStringFromBytes(b);
  8. ByteArrayDataSource source =
  9. new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
  10. data.value.setDataRef(new DataHandler(source));
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

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

  1. public void echoDataRef(Holder<DataStruct> data) {
  2. try {
  3. InputStream bis = null;
  4. bis = data.value.getDataRef().getDataSource().getInputStream();
  5. byte[] b = new byte[6];
  6. bis.read(b, 0, 6);
  7. String string = IOUtils.newStringFromBytes(b);
  8. ByteArrayDataSource source =
  9. new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
  10. data.value.setDataRef(new DataHandler(source));
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

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

  1. public void echoDataRef(Holder<DataStruct> data) {
  2. try {
  3. InputStream bis = null;
  4. bis = data.value.getDataRef().getDataSource().getInputStream();
  5. byte[] b = new byte[6];
  6. bis.read(b, 0, 6);
  7. String string = IOUtils.newStringFromBytes(b);
  8. ByteArrayDataSource source =
  9. new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
  10. data.value.setDataRef(new DataHandler(source));
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. }
  14. }

相关文章