Java Code Examples for org.apache.commons.io.HexDump#dump()
The following examples show how to use
org.apache.commons.io.HexDump#dump() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GssClient.java From ats-framework with Apache License 2.0 | 6 votes |
private int traceBeforeNegotiate() { int beforeNumSubjectCreds = 0; // Traces all credentials too. if (subject != null) { log.debug("[" + getName() + "] AUTH_NEGOTIATE as subject " + subject.toString()); beforeNumSubjectCreds = subject.getPrivateCredentials().size(); } if (negotiationToken != null && negotiationToken.length > 0) { try { OutputStream os = new ByteArrayOutputStream(); HexDump.dump(negotiationToken, 0, os, 0); log.debug("[" + getName() + "] AUTH_NEGOTIATE Process token from acceptor==>\n" + os.toString()); } catch (IOException e) {} } return beforeNumSubjectCreds; }
Example 2
Source File: GssClient.java From ats-framework with Apache License 2.0 | 6 votes |
private void traceAfterNegotiate( int beforeNumSubjectCreds ) { if (subject != null) { int afterNumSubjectCreds = subject.getPrivateCredentials().size(); if (afterNumSubjectCreds > beforeNumSubjectCreds) { log.debug("[" + getName() + "] AUTH_NEGOTIATE have extra credentials."); // Traces all credentials too. log.debug("[" + getName() + "] AUTH_NEGOTIATE updated subject=" + subject.toString()); } } if (negotiationToken != null && negotiationToken.length > 0) { try { OutputStream os = new ByteArrayOutputStream(); HexDump.dump(negotiationToken, 0, os, 0); log.debug("[" + getName() + "] AUTH_NEGOTIATE Send token to acceptor==>\n" + os.toString()); } catch (IOException e) {} } }
Example 3
Source File: HttpTransportTest.java From chassis with Apache License 2.0 | 6 votes |
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { logger.info("Sending headers: " + request.getHeaders()); if (body.length > 0) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(body, 0, baos, 0); logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim()); } else { logger.info("Sending empty body to [{}]!", request.getURI()); } return execution.execute(request, body); }
Example 4
Source File: DumpUtils.java From kotlogram with MIT License | 5 votes |
public static <T extends TLObject> void dump(T object, byte[] serialized) { try { String path = getFilePath(object.getClass()); FileUtils.writeStringToFile(new File(dumpDir + path + ".json"), toJson(object), Charset.forName("UTF-8")); FileUtils.writeStringToFile(new File(dumpDir + path + ".dump"), StreamUtils.toHexString(serialized), Charset.forName("UTF-8")); HexDump.dump(serialized, 0, new FileOutputStream(dumpDir + path + ".dump2"), 0); // More friendly dump } catch (IOException e) { e.printStackTrace(); } }
Example 5
Source File: UberUtil.java From antsdb with GNU Lesser General Public License v3.0 | 5 votes |
public static String hexDump(byte[] bytes) { ByteArrayOutputStream buf = new ByteArrayOutputStream(); try { HexDump.dump(bytes, 0, buf, 0); return buf.toString(); } catch (Exception x) { } return ""; }
Example 6
Source File: CmdConsume.java From pulsar with Apache License 2.0 | 5 votes |
/** * Interprets the message to create a string representation * * @param message * The message to interpret * @param displayHex * Whether to display BytesMessages in hexdump style, ignored for simple text messages * @return String representation of the message */ private String interpretMessage(Message<byte[]> message, boolean displayHex) throws IOException { StringBuilder sb = new StringBuilder(); String properties = Arrays.toString(message.getProperties().entrySet().toArray()); String data; byte[] msgData = message.getData(); ByteArrayOutputStream out = new ByteArrayOutputStream(); if (!displayHex) { data = new String(msgData); } else { HexDump.dump(msgData, 0, out, 0); data = new String(out.toByteArray()); } String key = null; if (message.hasKey()) { key = message.getKey(); } sb.append("key:[").append(key).append("], "); sb.append("properties:").append(properties).append(", "); sb.append("content:").append(data); return sb.toString(); }
Example 7
Source File: DumpUtils.java From kotlogram with MIT License | 5 votes |
public static <T extends TLObject> void dump(T object, byte[] serialized) { try { String path = getFilePath(object.getClass()); FileUtils.writeStringToFile(new File(dumpDir + path + ".json"), toJson(object), Charset.forName("UTF-8")); FileUtils.writeStringToFile(new File(dumpDir + path + ".dump"), StreamUtils.toHexString(serialized), Charset.forName("UTF-8")); HexDump.dump(serialized, 0, new FileOutputStream(dumpDir + path + ".dump2"), 0); // More friendly dump } catch (IOException e) { e.printStackTrace(); } }
Example 8
Source File: HybridServiceTest.java From chassis with Apache License 2.0 | 5 votes |
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (body.length > 0) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(body, 0, baos, 0); logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim()); } else { logger.info("Sending empty body to [{}]!", request.getURI()); } return execution.execute(request, body); }
Example 9
Source File: WebSocketDocsTest.java From chassis with Apache License 2.0 | 5 votes |
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (body.length > 0) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(body, 0, baos, 0); logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim()); } else { logger.info("Sending empty body to [{}]!", request.getURI()); } return execution.execute(request, body); }
Example 10
Source File: SharedTest.java From chassis with Apache License 2.0 | 5 votes |
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (body.length > 0) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(body, 0, baos, 0); logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim()); } else { logger.info("Sending empty body to [{}]!", request.getURI()); } return execution.execute(request, body); }
Example 11
Source File: MetricsTest.java From chassis with Apache License 2.0 | 5 votes |
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { if (body.length > 0) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(body, 0, baos, 0); logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim()); } else { logger.info("Sending empty body to [{}]!", request.getURI()); } return execution.execute(request, body); }
Example 12
Source File: EventHelper.java From mt-flume with Apache License 2.0 | 5 votes |
public static String dumpEvent(Event event, int maxBytes) { StringBuilder buffer = new StringBuilder(); if (event == null || event.getBody() == null) { buffer.append("null"); } else if (event.getBody().length == 0) { // do nothing... in this case, HexDump.dump() will throw an exception } else { byte[] body = event.getBody(); byte[] data = Arrays.copyOf(body, Math.min(body.length, maxBytes)); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { HexDump.dump(data, 0, out, 0); String hexDump = new String(out.toByteArray()); // remove offset since it's not relevant for such a small dataset if(hexDump.startsWith(HEXDUMP_OFFSET)) { hexDump = hexDump.substring(HEXDUMP_OFFSET.length()); } buffer.append(hexDump); } catch (Exception e) { if(LOGGER.isInfoEnabled()) { LOGGER.info("Exception while dumping event", e); } buffer.append("...Exception while dumping: ").append(e.getMessage()); } String result = buffer.toString(); if(result.endsWith(EOL) && buffer.length() > EOL.length()) { buffer.delete(buffer.length() - EOL.length(), buffer.length()).toString(); } } return "{ headers:" + event.getHeaders() + " body:" + buffer + " }"; }
Example 13
Source File: RDBParserImpl0006Test.java From Redis-Synyed with Apache License 2.0 | 4 votes |
/** * 显示RDB字节内容以及格式化 */ @Test public void showRDBDumpData() throws Exception { HexDump.dump(rdbData, 0, System.out, 0); }
Example 14
Source File: SerDeTest.java From chassis with Apache License 2.0 | 4 votes |
private static void dumpBytes(byte[] bytes) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(bytes, 0, baos, 0); logger.info("Serialized object to: \n{}", baos.toString(Charsets.UTF_8.name()).trim()); }
Example 15
Source File: ScalaCaseClassTest.java From chassis with Apache License 2.0 | 3 votes |
private static void dumpToLog(MessageSerDe serDe, byte[] data) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); HexDump.dump(data, 0, baos, 0); logger.info("Serialized object using [{}] to: \n{}", serDe.getMessageFormatName(), baos.toString(Charsets.UTF_8.name()).trim()); }