List of utility methods to do CSV String Convert
String | csvDecodeString(String value) Used to decode a value that was encoded with the csvEncodeString function. return value.replaceAll("\\\\(?=,)", ""); |
char | csvDelimiter(String line) csv Delimiter int semiCount = 0, commaCount = 0; for (int walk = 0; walk < line.length(); walk++) { char ch = line.charAt(walk); switch (ch) { case ';': semiCount++; break; case ',': ... |
String | csvEncode(int value) Encodes the given value to a CSV acceptable value. return csvEncode(String.valueOf(value));
|
String | csvEncodeString(String value) This function is used when you build a comma separated list of filter values where you can't use an Object []. return value.replaceAll("(?!\\\\),", "\\\\,"); |
String | csvQuote(String value) csv Quote return '"' + value.replaceAll("\"", "\"\"") + '"'; |
String | csvString(Object[] objects) Convert an array of objects to a CSV string String str = objects[0].toString(); for (int i = 1; i < objects.length; i++) { str += "," + objects[i].toString(); return str; |
String | csvstring(Object[] str) Create a CSV string from an array of objects. if (str.length > 0) { StringBuilder csvBuilder = new StringBuilder(); for (Object n : str) { csvBuilder.append(n.toString()).append(","); csvBuilder.deleteCharAt(csvBuilder.length() - 1); return csvBuilder.toString(); } else { ... |
String | csvTitleToTag(String title, int index) csv Title To Tag StringBuilder tag = new StringBuilder(); for (char c : title.toCharArray()) { if (Character.isLetterOrDigit(c)) tag.append(Character.toLowerCase(c)); String tagString = tag.toString(); return tagString.isEmpty() ? String.format("column%d", index) : tagString; |
String[] | csvToArray(String dirs) csv To Array return dirs != null ? dirs.split(";") : new String[0]; |
String[][] | csvToArray(String line) csv To Array return csvTextToArray(line, ','); |