com.bloxbean.cardano.client.util.StringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cardano-client-common Show documentation
Show all versions of cardano-client-common Show documentation
Cardano Client Lib - Common Module
The newest version!
package com.bloxbean.cardano.client.util;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.StandardCharsets;
public class StringUtils {
public static String[] splitStringEveryNCharacters(String text, int n) {
return text.split("(?<=\\G.{" + n + "})");
}
public static boolean isEmpty(final String string) {
return string == null || string.isEmpty();
}
public static boolean isUtf8String(byte[] bytes) {
CharsetDecoder decoder =
StandardCharsets.UTF_8.newDecoder();
try {
decoder.decode(
ByteBuffer.wrap(bytes));
} catch (CharacterCodingException ex) {
return false;
}
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy