public static String getHexDataDumpAsString(byte[] buf) { return getHexDataDumpAsString(buf, buf.length); }
public static void dumpHexData(PrintStream out, byte[] buf) { dumpHexData(out, buf, buf.length); }
@Override public void setBody(byte[] body, ContentType type) { // Call the super method super.setBody(body, type); // Set the hex display value jta.setText(HexDump.getHexDataDumpAsString(body)); jta.setCaretPosition(0); }
public static String getHexDataDumpAsString(byte[] buf, int len) { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream out = new PrintStream(baos, false, Charsets.UTF_8.name()); dumpHexData(out, buf, len); return new String(baos.toByteArray(), Charsets.UTF_8.name()); } catch(UnsupportedEncodingException ex) { throw new RuntimeException(ex); } }
@Override public void setEntity(ReqEntity entity) { if(entity instanceof ReqEntityByteArray) { ReqEntityByteArray e = (ReqEntityByteArray) entity; // content-type charset jp_content_type_charset.setContentTypeCharset(e.getContentType()); // Set body: body = e.getBody(); jta.setText(HexDump.getHexDataDumpAsString(e.getBody())); } }
byte[] data = FileUtil.getContentAsBytes(f); body = data; jta.setText(HexDump.getHexDataDumpAsString(data)); jta.setCaretPosition(0);