/** * Reads from String and splits into strings according to the delimiter, * taking note of quoted strings. * * Handles DOS (CRLF), Unix (LF), and Mac (CR) line-endings equally. * * @param line * input line - not {@code null} * @param delim * delimiter (e.g. comma) * @return array of strings * @throws IOException * also for unexpected quote characters */ public static String[] csvSplitString(String line, char delim) throws IOException { return csvReadFile(new BufferedReader(new StringReader(line)), delim); }
/** * * @param alias the file name or alias * @param recycle whether the file should be re-started on EOF * @param ignoreFirstLine whether the file contains a file header which will be ignored * @param delim the delimiter to use for parsing * @return the parsed line, will be empty if the file is at EOF * @throws IOException when reading of the aliased file fails, or the file was not reserved properly */ public synchronized String[] getParsedLine(String alias, boolean recycle, boolean ignoreFirstLine, char delim) throws IOException { BufferedReader reader = getReader(alias, recycle, ignoreFirstLine); return CSVSaveService.csvReadFile(reader, delim); }
private Sample nextSample() { String[] data; try { data = CSVSaveService.csvReadFile(reader, separator); Sample sample = null; if (data.length > 0) { if (data.length != columnCount+numberOfSampleVariablesInCsv) { throw new SampleException("Mismatch between expected number of columns:"+columnCount+" and columns in CSV file:"+data.length+ ", check your jmeter.save.saveservice.* configuration or check line is complete"); } sample = new Sample(row++, metadata, data); } return sample; } catch (IOException e) { throw new SampleException("Could not read sample <" + row + ">", e); } }
while ((parts = csvReadFile(dataReader, delim)).length != 0) { lineNumber++; SampleEvent event = CSVSaveService.makeResultFromDelimitedString(parts, saveConfig, lineNumber);