Guest User

Untitled

a guest
Jun 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. if (be.isRepeatable()) {
  2. try {
  3. System.out.println();
  4. System.out.println(be.getContentType());
  5. if (null != be.getContentEncoding()) {
  6. System.out.println(be.getContentEncoding());
  7. }
  8. System.out.println("Content-Length: " + be.getContentLength());
  9. try (InputStream is = be.getContent()) {
  10. int pos = 0;
  11. byte[] bytes = new byte[24];
  12. int c;
  13. while (-1 != (c = is.read(bytes))) {
  14. StringBuilder sb = new StringBuilder();
  15. sb.append(String.format("%08x ", pos));
  16. for (int i = 0; i < c; i++) {
  17. sb.append(String.format("%02x ", bytes[i]));
  18. }
  19. for (int i = c; i < bytes.length; i++) {
  20. sb.append(" ");
  21. }
  22. sb.append(" ");
  23. for (int i = 0; i < c; i++) {
  24. sb.append(String.format("%c", (bytes[i] >= 32 && bytes[i] < 127) ? bytes[i] : '.'));
  25. }
  26. pos += c;
  27. System.out.println(sb.toString());
  28. }
  29. } finally {
  30. }
  31. } catch (IOException ex) {
  32. ex.printStackTrace();
  33. }
  34. }
Add Comment
Please, Sign In to add comment