Package cdc.util.csv
Class CsvUtils
- java.lang.Object
-
- cdc.util.csv.CsvUtils
-
public final class CsvUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringescape(String text, boolean addExternalQuotes)Escape a string and add external quotes ('"') if asked.static StringescapeIfNecessary(String text, char separator)Escape a string if necessary.static booleanneedsEscape(String text, char separator)Return whether a string value needs to be escaped.static voidprint(CharSequence[] items, char separator, PrintStream out)static voidprint(CharSequence[] items, char separator, PrintWriter out)
-
-
-
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.
-
print
public static void print(CharSequence[] items, char separator, PrintWriter out)
-
print
public static void print(CharSequence[] items, char separator, PrintStream out)
-
-