001// Licensed under the MIT license. See LICENSE file in the project root for full license information.
002
003package de.bytefish.pgbulkinsert.util;
004
005import java.nio.charset.Charset;
006import java.nio.charset.StandardCharsets;
007
008public class StringUtils {
009
010        private static Charset utf8Charset = StandardCharsets.UTF_8;
011
012    private StringUtils() {}
013
014    public static boolean isNullOrWhiteSpace(String input) {
015        return input == null || input.trim().length() == 0;
016    }
017
018    public static byte[] getUtf8Bytes(String value) {
019        return value.getBytes(utf8Charset);
020    }
021
022    public static String removeNullCharacter(String data) {
023                if (data == null) {
024                        return null;
025                }
026
027                return data.replaceAll("\u0000", "");
028        }
029}