All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.bytefish.pgbulkinsert.util.StringUtils Maven / Gradle / Ivy

There is a newer version: 7.0.1
Show newest version
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

package de.bytefish.pgbulkinsert.util;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class StringUtils {

	private static Charset utf8Charset = StandardCharsets.UTF_8;

    private StringUtils() {}

    public static boolean isNullOrWhiteSpace(@Nullable String input) {
        return input == null || input.trim().length() == 0;
    }

    public static byte[] getUtf8Bytes(String value) {
        return value.getBytes(utf8Charset);
    }

    @Nullable
    public static String removeNullCharacter(@Nullable String data) {
		if (data == null) {
			return data;
		}

		return data.replaceAll("\u0000", "");
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy