Package cdc.util.csv

Class CsvUtils


  • public final class CsvUtils
    extends Object
    • Method Detail

      • needsEscape

        public static boolean needsEscape​(String text,
                                          char separator)
        Return whether a string value needs to be escaped. This is the case when:
        • the string contains '"' character,
        • the string contains the separator character,
        • the string has multiple lines.
        Parameters:
        text - The string to test.
        separator - The separator that should be used.
        Returns:
        whether text needs to be escaped or not.
      • escape

        public static String escape​(String text,
                                    boolean addExternalQuotes)
        Escape a string and add external quotes ('"') if asked. Internal processing replaces '"' by 2 '"'.
        Parameters:
        text - The string to escape.
        addExternalQuotes - If true, external quotes are added.
        Returns:
        The escaped string.
      • escapeIfNecessary

        public static String escapeIfNecessary​(String text,
                                               char separator)
        Escape a string if necessary.
        Parameters:
        text - The string to escape.
        separator - The separator to be used.
        Returns:
        The input string or its escaped version.