FixedWidthReader extends FileReader implements DataReader<FixedWidthReadOptions> { public ColumnType[] detectColumnTypes(Reader reader, FixedWidthReadOptions options) { boolean header = options.header(); int linesToSkip = header ? 1 : 0; AbstractParser<?> parser = fixedWidthParser(options); try { return getColumnTypes(reader, options, linesToSkip, parser); } finally { parser.stopParsing(); } } FixedWidthReader(); static void register(ReaderRegistry registry); Table read(FixedWidthReadOptions options); String printColumnTypes(FixedWidthReadOptions options); ColumnType[] detectColumnTypes(Reader reader, FixedWidthReadOptions options); @Override Table read(Source source);  }
@Test public void testDataTypeDetection() throws Exception { InputStream stream = new FileInputStream(new File("../data/fixed_width_cars_test.txt")); FixedWidthReadOptions options = FixedWidthReadOptions.builder(stream) .header(true) .columnSpecs(car_fields_specs) .padding('_') .systemLineEnding() .sample(false) .locale(Locale.getDefault()) .minimizeColumnSizes() .build(); Reader reader = new FileReader("../data/fixed_width_missing_values.txt"); ColumnType[] columnTypes = new FixedWidthReader().detectColumnTypes(reader, options); assertArrayEquals(car_types, columnTypes); }