public static @NotNull String bytesToString(byte @NotNull [] bytes, final @NotNull Charset defaultCharset) {
    if (bytes.length == 0) return "";
    Charset charset = new CharsetToolkit(bytes, defaultCharset, false).guessEncoding(bytes.length);
    if (charset == null) charset = defaultCharset; // binary content. This is silly but method contract says to return something anyway
    return decodeString(bytes, charset);
  }
public static @NotNull String bytesToString(byte @NotNull [] bytes, final @NotNull Charset defaultCharset)