Package org.apache.solr.internal.csv
Class CSVUtils
- java.lang.Object
-
- org.apache.solr.internal.csv.CSVUtils
-
public class CSVUtils extends Object
Utility methods for dealing with CSV files
-
-
Constructor Summary
Constructors Constructor Description CSVUtils()CSVUtilsinstances should NOT be constructed in standard programming.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String[][]parse(String s)Parses the given String according to the defaultCSVStrategy.static String[]parseLine(String s)Parses the first line only according to the defaultCSVStrategy.static StringprintLine(String[] values, CSVStrategy strategy)Converts an array of string values into a single CSV line.
-
-
-
Method Detail
-
printLine
public static String printLine(String[] values, CSVStrategy strategy)
Converts an array of string values into a single CSV line. Allnullvalues are converted to the string"null", all strings equal to"null"will additionally get quotes around.- Parameters:
values- the value array- Returns:
- the CSV string, will be an empty string if the length of the value array is 0
-
parse
public static String[][] parse(String s) throws IOException
Parses the given String according to the defaultCSVStrategy.- Parameters:
s- CSV String to be parsed.- Returns:
- parsed String matrix (which is never null)
- Throws:
IOException- in case of error
-
parseLine
public static String[] parseLine(String s) throws IOException
Parses the first line only according to the defaultCSVStrategy.Parsing empty string will be handled as valid records containing zero elements, so the following property holds: parseLine("").length == 0.
- Parameters:
s- CSV String to be parsed.- Returns:
- parsed String vector (which is never null)
- Throws:
IOException- in case of error
-
-