Java Utililty Methods UTF8

List of utility methods to do UTF8

Description

The list of methods to do UTF8 are organized into topic(s).

Method

byte[]getBytesUtf8(final String string)
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.
return getBytes(string, StandardCharsets.UTF_8);
FilegetFile(String outputFolder, String fileName)
get File
File file = Paths.get(outputFolder, fileName).toFile();
return file;
ArrayListgetFiles(String InputFilePath)
get Files
ArrayList<File> fileList = new ArrayList<File>();
File dir = null;
String filePattern = null;
InputFilePath.trim();
if (InputFilePath.lastIndexOf('/') > 0) {
    dir = new File((InputFilePath.substring(0, InputFilePath.lastIndexOf('/') + 1) == "" ? "."
            : InputFilePath.substring(0, InputFilePath.lastIndexOf('/') + 1) + "\\"));
    filePattern = (InputFilePath.substring(InputFilePath.lastIndexOf('/') + 1));
...
ListgetOutputFromCommand(boolean print, List command)
Execute a shell command and retrieve its output.
try {
    StringJoiner sj = new StringJoiner(" ", "$ ", "");
    command.stream().forEach(sj::add);
    System.out.println(sj.toString());
    Path tempFile = Files.createTempFile("test-output", null);
    ProcessBuilder builder = new ProcessBuilder(command);
    builder.redirectErrorStream(true);
    builder.redirectOutput(Redirect.to(tempFile.toFile()));
...
StringgetStringFromUTF8Bytes(byte[] utf8Bytes)
get String From UTF Bytes
return new String(utf8Bytes, UTF_8);
CharsetgetUtf8()
get Utf
return UTF8;
CharsetgetUTF8()
get UTF
return Charset.forName("UTF-8");
CharsetgetUtf8()
Simply returns the value of Charset#forName(String) with value of #UTF8_NAME .
return Charset.forName(UTF8_NAME);
StringgetUTF8(byte[] data, int offset, int length)
get UTF
return new String(data, offset, length, UTF8);
byte[]getUTF8Bytes(String s)
get UTF Bytes
if (s != null && s.length() >= 0) {
    return s.getBytes(UTF_8);
return null;