本文整理了Java中org.apache.cxf.helpers.IOUtils.newStringFromBytes()
方法的一些代码示例,展示了IOUtils.newStringFromBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.newStringFromBytes()
方法的具体详情如下:
包路径:org.apache.cxf.helpers.IOUtils
类名称: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
public String toString() {
return IOUtils.newStringFromBytes(buf, 0, count);
}
};
代码示例来源:origin: apache/cxf
public String toString() {
return IOUtils.newStringFromBytes(buf, 0, count);
}
代码示例来源:origin: org.apache.cxf/cxf-core
public String toString() {
return IOUtils.newStringFromBytes(buf, 0, count);
}
代码示例来源:origin: org.apache.cxf/cxf-core
/**
* Use this function instead of new String(byte[], int, int)
* to avoid surprises from non-standard default encodings.
* @param bytes
* @param start
* @param length
*/
public static String newStringFromBytes(byte[] bytes, int start, int length) {
return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
}
代码示例来源:origin: org.apache.cxf/cxf-common-utilities
/**
* Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
* @param bytes
* @return
*/
public static String newStringFromBytes(byte[] bytes) {
return newStringFromBytes(bytes, UTF8_CHARSET.name());
}
代码示例来源:origin: org.apache.cxf/cxf-common-utilities
/**
* Use this function instead of new String(byte[], int, int)
* to avoid surprises from non-standard default encodings.
* @param bytes
* @param start
* @param length
* @return
*/
public static String newStringFromBytes(byte[] bytes, int start, int length) {
return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
/**
* Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
* @param bytes
*/
public static String newStringFromBytes(byte[] bytes) {
return newStringFromBytes(bytes, UTF8_CHARSET.name());
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
/**
* Use this function instead of new String(byte[], int, int)
* to avoid surprises from non-standard default encodings.
* @param bytes
* @param start
* @param length
*/
public static String newStringFromBytes(byte[] bytes, int start, int length) {
return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
}
代码示例来源:origin: org.apache.cxf/cxf-core
/**
* Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
* @param bytes
*/
public static String newStringFromBytes(byte[] bytes) {
return newStringFromBytes(bytes, UTF8_CHARSET.name());
}
代码示例来源:origin: org.apache.cxf/cxf-api
/**
* Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
* @param bytes
*/
public static String newStringFromBytes(byte[] bytes) {
return newStringFromBytes(bytes, UTF8_CHARSET.name());
}
代码示例来源:origin: apache/cxf
/**
* Use this function instead of new String(byte[]) to avoid surprises from non-standard default encodings.
* @param bytes
*/
public static String newStringFromBytes(byte[] bytes) {
return newStringFromBytes(bytes, UTF8_CHARSET.name());
}
代码示例来源:origin: apache/cxf
/**
* Use this function instead of new String(byte[], int, int)
* to avoid surprises from non-standard default encodings.
* @param bytes
* @param start
* @param length
*/
public static String newStringFromBytes(byte[] bytes, int start, int length) {
return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
}
代码示例来源:origin: org.apache.cxf/cxf-api
/**
* Use this function instead of new String(byte[], int, int)
* to avoid surprises from non-standard default encodings.
* @param bytes
* @param start
* @param length
*/
public static String newStringFromBytes(byte[] bytes, int start, int length) {
return newStringFromBytes(bytes, UTF8_CHARSET.name(), start, length);
}
代码示例来源:origin: apache/cxf
protected boolean equals(byte[] x, byte[] y) {
String xx = IOUtils.newStringFromBytes(x);
String yy = IOUtils.newStringFromBytes(y);
return xx.equals(yy);
}
代码示例来源:origin: org.apache.cxf/cxf-api
private String findBoundaryFromInputStream() throws IOException {
InputStream is = message.getContent(InputStream.class);
//boundary should definitely be in the first 2K;
PushbackInputStream in = new PushbackInputStream(is, 4096);
byte buf[] = new byte[2048];
int i = in.read(buf);
String msg = IOUtils.newStringFromBytes(buf, 0, i);
in.unread(buf, 0, i);
// Reset the input stream since we'll need it again later
message.setContent(InputStream.class, in);
// Use regex to get the boundary and return null if it's not found
Matcher m = INPUT_STREAM_BOUNDARY_PATTERN.matcher(msg);
return m.find() ? "--" + m.group(1) : null;
}
代码示例来源:origin: apache/cxf
public void echoData(Holder<String> text, Holder<DataHandler> data) {
try {
InputStream bis = null;
bis = data.value.getDataSource().getInputStream();
byte[] b = new byte[6];
bis.read(b, 0, 6);
String string = IOUtils.newStringFromBytes(b);
ByteArrayDataSource source =
new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
data.value = new DataHandler(source);
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: apache/cxf
public void echoData(Holder<String> text, Holder<DataHandler> data) {
try {
InputStream bis = null;
bis = data.value.getDataSource().getInputStream();
byte[] b = new byte[6];
bis.read(b, 0, 6);
String string = IOUtils.newStringFromBytes(b);
ByteArrayDataSource source =
new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
data.value = new DataHandler(source);
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: apache/cxf
public void echoDataRef(Holder<DataStruct> data) {
try {
InputStream bis = null;
bis = data.value.getDataRef().getDataSource().getInputStream();
byte[] b = new byte[6];
bis.read(b, 0, 6);
String string = IOUtils.newStringFromBytes(b);
ByteArrayDataSource source =
new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
data.value.setDataRef(new DataHandler(source));
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: apache/cxf
public void echoDataRef(Holder<DataStruct> data) {
try {
InputStream bis = null;
bis = data.value.getDataRef().getDataSource().getInputStream();
byte[] b = new byte[6];
bis.read(b, 0, 6);
String string = IOUtils.newStringFromBytes(b);
ByteArrayDataSource source =
new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
data.value.setDataRef(new DataHandler(source));
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: apache/cxf
public void echoDataRef(Holder<DataStruct> data) {
try {
InputStream bis = null;
bis = data.value.getDataRef().getDataSource().getInputStream();
byte[] b = new byte[6];
bis.read(b, 0, 6);
String string = IOUtils.newStringFromBytes(b);
ByteArrayDataSource source =
new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
data.value.setDataRef(new DataHandler(source));
} catch (IOException e) {
e.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!