@Test public void readList2() throws Exception { String inputText = "A\n" + "B\n" + "C\n" + "D\n" + "E\n" + "F\n"; VType value = TextIO.readList(new StringReader(inputText)); assertThat(value, instanceOf(VStringArray.class)); VStringArray array = (VStringArray) value; assertThat(array.getData(), equalTo(Arrays.asList("A", "B", "C", "D", "E", "F"))); }
public static VType readList(Reader reader) throws IOException { Matcher doubleMatcher = pDouble.matcher(""); List<String> lines = new ArrayList<>(); BufferedReader br = new BufferedReader(reader); String line; boolean numbers = true; while ((line = br.readLine()) != null) { lines.add(line); if (!doubleMatcher.reset(line).matches()) { numbers = false; } } if (numbers) { ListDouble numberList = convertToListDouble(lines); return ValueFactory.toVType(numberList); } else { return ValueFactory.toVType(lines); } }
TextIO { public static VType readList(Reader reader) throws IOException { Matcher doubleMatcher = pDouble.matcher(""); List<String> lines = new ArrayList<>(); BufferedReader br = new BufferedReader(reader); String line; boolean numbers = true; while ((line = br.readLine()) != null) { lines.add(line); if (!doubleMatcher.reset(line).matches()) { numbers = false; } } if (numbers) { ListDouble numberList = convertToListDouble(lines); return ValueFactory.toVType(numberList); } else { return ValueFactory.toVType(lines); } } }
TextIO { public static VType readList(Reader reader) throws IOException { Matcher doubleMatcher = pDouble.matcher(""); List<String> lines = new ArrayList<>(); BufferedReader br = new BufferedReader(reader); String line; boolean numbers = true; while ((line = br.readLine()) != null) { lines.add(line); if (!doubleMatcher.reset(line).matches()) { numbers = false; } } if (numbers) { ListDouble numberList = convertToListDouble(lines); return ValueFactory.toVType(numberList); } else { return ValueFactory.toVType(lines); } }  }
TextIO { public static VType readList(Reader reader) throws IOException { Matcher doubleMatcher = pDouble.matcher(""); List<String> lines = new ArrayList<>(); BufferedReader br = new BufferedReader(reader); String line; boolean numbers = true; while ((line = br.readLine()) != null) { lines.add(line); if (!doubleMatcher.reset(line).matches()) { numbers = false; } } if (numbers) { ListDouble numberList = convertToListDouble(lines); return ValueFactory.toVType(numberList); } else { return ValueFactory.toVType(lines); } }  static VType readList(Reader reader); static void writeList(VType vType, Writer writer); }
TextIO { public static VType readList(Reader reader) throws IOException { Matcher doubleMatcher = pDouble.matcher(""); List<String> lines = new ArrayList<>(); BufferedReader br = new BufferedReader(reader); String line; boolean numbers = true; while ((line = br.readLine()) != null) { lines.add(line); if (!doubleMatcher.reset(line).matches()) { numbers = false; } } if (numbers) { ListDouble numberList = convertToListDouble(lines); return ValueFactory.toVType(numberList); } else { return ValueFactory.toVType(lines); } }  static VType readList(Reader reader); static void writeList(VType vType, Writer writer);  }