public String toString() { return IOUtils.newStringFromBytes(buf, 0, count); } };
public String toString() { return IOUtils.newStringFromBytes(buf, 0, count); }
public String toString() { return IOUtils.newStringFromBytes(buf, 0, count); }
/** * 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); }
/** * 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()); }
/** * 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); }
/** * 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()); }
/** * 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); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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); }
/** * 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); }
protected boolean equals(byte[] x, byte[] y) { String xx = IOUtils.newStringFromBytes(x); String yy = IOUtils.newStringFromBytes(y); return xx.equals(yy); }
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; }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }