code: public static String limitedBytesToString(byte[] bytes) {
          if(bytes.length <= 1000) {
              return Arrays.toString(bytes);
          } else {
              byte[] firstBytes = new byte[1000];
              System.arraycopy(bytes, 0, firstBytes, 0, 1000);
              return Arrays.toString(firstBytes);
          }
      }
docs: If the byte array length is less than 1000, returns the result of calling Arrays.toString on the
  supplied byte array.  Otherwise returns the result of calling Arrays.toString on a byte array containing
  the first 1000 bytes in the supplied byte array.