List of utility methods to do CSV String Create
String | toCsvLine(final String[] parts) Turns a string array into a CSV line. final StringBuffer line = new StringBuffer(""); for (final String part : parts) { if (line.length() > 0) { line.append(CSV_DELIMITER); line.append(part.replaceAll(CSV_QUOTE, CSV_QUOTE + CSV_QUOTE)); return line.toString(); ... |
String | toCSVString(double[] d) to CSV String String ret = ""; for (int i = 0; i < d.length; i++) { ret += d[i] + ";"; ret = ret.substring(0, ret.length() - 1); return ret; |
String | toCsvString(Object object) to Csv String if (object != null) { return "\"" + object.toString().replace("\\", "\\\\").replace("\'", "\\\'").replace("\"", "\\\"") + "\""; } else { return "\\N"; |
String | toCSVString(Object[] pStringArray) Converts a string array to a string of comma-separated values. return toCSVString(pStringArray, ", "); |
String | toCSVString(String s) to CSV String StringBuilder sb = new StringBuilder(s.length() + 1); sb.append('\''); int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); switch (c) { case '\0': sb.append("%00"); ... |
String | toCsvString(String text, char separator, char quote, String quoteEscaped) to Csv String boolean containLineSeparator = text.indexOf("\n") != -1 && text.indexOf("\r") != -1; boolean containSeparator = text.indexOf(separator) != -1; if (containLineSeparator || containSeparator || text.startsWith("" + quote)) { text = text.replace("" + quote, quoteEscaped); return quote + text + quote; } else { return text; |
String | toCsvString(String text, String splitString, String replaceSplitChar) csv value cracch quot if it contain a line-separator. boolean containLineSeparator = text.indexOf("\n") != -1; if (!containLineSeparator) { containLineSeparator = text.indexOf("\r") != -1; text = text.replace(splitString, replaceSplitChar); if (containLineSeparator) { text = text.replace("\"", "\"\""); return "\"" + text + "\""; ... |
String | toCSVString(String[] fields) to CSV String StringBuilder b = new StringBuilder(); for (String fld : fields) { if (b.length() > 0) { b.append(','); String field = escapeString(fld, new char[] { '\"' }, '\"'); b.append('\"').append(field).append('\"'); return b.toString(); |