AirportLoader { public List<String> tokenize(String line) { List<String> list = new ArrayList<>(); String[] parts = line.split("\\s*,\\s*"); for (int i = 0; i < parts.length; i++) { String item = parts[i]; if (item.length() > 0 && item.charAt(0) == '"' && item.charAt(item.length() - 1) != '"') { i++; while (i < parts.length && parts[i].charAt(parts[i].length() - 1) != '"') { item += "," + parts[i]; i++; } if (i == parts.length) { throw new WeatherException("Non-closed double quote !"); } item+="," +parts[i]; } if (item.startsWith("\"") && item.endsWith("\"")) { item = item.substring(1, item.length()-1); } list.add(item); } return list; } AirportLoader(String baseEndpoint); void upload(InputStream airportDataStream); List<String> tokenize(String line); static void main(String args[]);  }
@Test public void testTokenize() { assertEquals(Arrays.asList("a","b","-2"), target.tokenize("\"a\",b,-2")); assertEquals(Arrays.asList("a,b","-2"), target.tokenize("\"a,b\",-2")); }