public static byte[] getBytes(final String value) { return getBytes(value, DEFAULT_CHARSET); }
public static String fromBytes(final byte[] bytes) { return fromBytes(bytes, DEFAULT_CHARSET); }
"Creating map {} in context: \n{}", System.identityHashCode(this), StringUtil.formatStackTrace(Thread.currentThread().getStackTrace()));
public ErrorResponseWriter errorMessage(String errorMessage) { this.errorMessage = getBytes(errorMessage); return this; }
public static String fromBytes(final byte[] bytes) { return fromBytes(bytes, DEFAULT_CHARSET); }
public ErrorResponseWriter errorMessage(String errorMessage) { this.errorMessage = getBytes(errorMessage); return this; }
public static String digestAsHex(final MessageDigest messageDigest) { final byte[] digest = messageDigest.digest(); final byte[] hexByteArray = BitUtil.toHexByteArray(digest); return fromBytes(hexByteArray); }
public static byte[] getBytes(final String value) { return getBytes(value, DEFAULT_CHARSET); }
public static String digestAsHex(final MessageDigest messageDigest) { final byte[] digest = messageDigest.digest(); final byte[] hexByteArray = BitUtil.toHexByteArray(digest); return fromBytes(hexByteArray); }
public ErrorResponseWriter errorMessage(String errorMessage, Object... args) { this.errorMessage = getBytes(format(errorMessage, args)); return this; }
public String host() { final int hostLength = hostLength(); final byte[] tmp = new byte[hostLength]; hostBuffer.getBytes(0, tmp, 0, hostLength); return fromBytes(tmp); }
public ErrorResponseWriter errorMessage(String errorMessage, Object... args) { this.errorMessage = getBytes(format(errorMessage, args)); return this; }
public String host() { final int hostLength = hostLength(); final byte[] tmp = new byte[hostLength]; hostBuffer.getBytes(0, tmp, 0, hostLength); return fromBytes(tmp); }
public static void write(final File file, final String data) throws IOException { try (FileOutputStream os = new FileOutputStream(file)) { os.write(getBytes(data)); } }
public static boolean canRead(final File file, final MessageDigest messageDigest) { boolean isReadable = false; final File checksum = new File(file.getAbsolutePath() + "." + messageDigest.getAlgorithm().toLowerCase()); if (file.exists() && checksum.exists()) { String checksumDigest = null; String checksumFileName = null; try (InputStream is = new FileInputStream(checksum)) { final byte[] data = new byte[(int) checksum.length()]; read(is, data); final String content = fromBytes(data); final String[] parts = content.split(" "); checksumDigest = parts[0]; checksumFileName = parts[1]; } catch (final IOException e) { // ignore } if (checksumFileName.equals(file.getName())) { try (InputStream is = new FileInputStream(file)) { updateDigest(messageDigest, is); } catch (final IOException e) { // ignore } final String digest = digestAsHex(messageDigest); isReadable = digest.equals(checksumDigest); } } return isReadable; }
public static void write(final File file, final String data) throws IOException { try (FileOutputStream os = new FileOutputStream(file)) { os.write(getBytes(data)); } }
public static boolean canRead(final File file, final MessageDigest messageDigest) { boolean isReadable = false; final File checksum = new File(file.getAbsolutePath() + "." + messageDigest.getAlgorithm().toLowerCase()); if (file.exists() && checksum.exists()) { String checksumDigest = null; String checksumFileName = null; try (InputStream is = new FileInputStream(checksum)) { final byte[] data = new byte[(int) checksum.length()]; read(is, data); final String content = fromBytes(data); final String[] parts = content.split(" "); checksumDigest = parts[0]; checksumFileName = parts[1]; } catch (final IOException e) { // ignore } if (checksumFileName.equals(file.getName())) { try (InputStream is = new FileInputStream(file)) { updateDigest(messageDigest, is); } catch (final IOException e) { // ignore } final String digest = digestAsHex(messageDigest); isReadable = digest.equals(checksumDigest); } } return isReadable; }
public void setValue(final String value) { this.value.wrap(getBytes(value)); this.isSet = true; }
public SocketAddress host(final String host) { final byte[] hostBytes = getBytes(host); return host(hostBytes, 0, hostBytes.length); }
public SocketAddress host(final String host) { final byte[] hostBytes = getBytes(host); return host(hostBytes, 0, hostBytes.length); }