If you're using the header of your CSV file as the nameMapping
then you'll never need to know how many columns there are, you'd just use them. If they're not appropriate for mapping (their names don't correspond with the setters in your bean) then you need to supply your own nameMapping
with the correct number of elements.
If your CSV file has a header and you know that you only ever want the first 2 columns, then you can simply provide a nameMapping array (and optionally a cell processor array) the same size as the header, but with only the first 2 elements populated.
String[] header = beanReader.getHeader(true);
// only interested in first 2 columns (rest set to null)
String[] nameMapping =
Arrays.copyOf(new String[]{"column1","column2"}, header.length);
// processors are optional, but you can populate these if you want
CellProcessor[] processors = new CellProcessor[header.length];
// TODO: read your CSV here...