List of utility methods to do CSV from
List | csvToList(String csv) csv To List List<String> list = new ArrayList<String>(); String[] splitString = csv.split(","); for (int i = 0; i < splitString.length; i++) { list.add(splitString[i].trim()); return list; |
List | CSVToList(String str) Converts a CSV string to a list of strings. List<String> list = new ArrayList<String>(); String[] valueString = str.split(","); for (String value : valueString) if (!value.equals("[]")) list.add(value); return list; |
String | formatAsCsv(List format As Csv StringBuffer buffer = new StringBuffer(); for (Iterator<String> i = stringList.iterator(); i.hasNext();) { String string = i.next(); buffer.append(string); if (i.hasNext()) { buffer.append(","); return buffer.toString(); |
String | formatCsvRecord(List CSV record formatter. StringBuilder fields = new StringBuilder(); String separator = String.valueOf(csvSeparator); for (Iterator<T> iter = csvRecord.iterator(); iter.hasNext();) { T object = iter.next(); if (object != null) { String field = object.toString().replace("\"", "\"\""); if (field.contains(separator) || field.contains("\"")) { field = "\"" + field + "\""; ... |
ArrayList | getArrayListFromCSV(String csvString) get Array List From CSV return helper1(csvString, CSV_SEPARATOR);
|
String | getAsCsv(List get As Csv return getAsCsv(tags.toArray(new String[tags.size()])); |
String | getCSV(List l) Takes a list of String Objects and returns a String with the all values from the list separated by a comma StringBuilder ret = new StringBuilder(); ; if (l != null) { for (int i = 0; i < l.size(); i++) { ret.append((String) l.get(i)); if (i + 1 < l.size()) { ret.append(","); return ret.toString(); |
String | getCSVFromList(List Create a comma seperated value (CSV) string form the passed in list String output = null; Iterator<String> iter = myList.iterator(); while (iter.hasNext()) { String curVal = (String) iter.next(); if (null == output) { output = curVal; } else { output = output + "," + curVal; ... |
String | getCSVFromList(List get CSV From List String output = null; Iterator<String> iter = myList.iterator(); while (iter.hasNext()) { String curVal = (String) iter.next(); if (null == output) { output = curVal; } else { output = output + "," + curVal; ... |
List | getCSVList(String csvList) get CSV List if (csvList == null || csvList.length() == 0) return Collections.emptyList(); List<String> ret = new ArrayList<String>(Arrays.asList(csvList.split(","))); Iterator<String> iter = ret.iterator(); while (iter.hasNext()) { final String next = iter.next(); if (next == null || next.length() == 0) { iter.remove(); ... |