code: public static String toStringBinary(final byte [] b, int off, int len) {
      StringBuilder result = new StringBuilder();
      try {
        String first = new String(b, off, len, "ISO-8859-1");
        for (int i = 0; i < first.length(); ++i) {
          int ch = first.charAt(i) & 0xFF;
          if ((ch >= '0' && ch <= '9')
              || (ch >= 'A' && ch <= 'Z')
              || (ch >= 'a' && ch <= 'z')
              || " `~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/?".indexOf(ch) >= 0) {
            result.append(first.charAt(i));
          } else {
            result.append(String.format("\\x%02X", ch));
          }
        }
      } catch (UnsupportedEncodingException e) {
      }
      return result.toString();
    }
docs: Write a printable representation of a byte array. Non-printable
  characters are hex escaped in the format \\x%02X, eg:
  \x00 \x05 etc
  
  @param b array to write out
  @param off offset to start at
  @param len length to write
  @return string output