-2
I’m uploading a CSV file, and I’m already able to count how many lines there are, in our context are three lines as shown in the code below;
However I need now and how to get the maximum number of positions, I’m not sure how to catch, I know that by doing a debug I can know that the maximum number of positions is 10 as shown in the figure below;
I need to know how to create a line of code to get the amount of positions; this is my algorithm;
File arquivoLeitura = new File(getArquivo());
LineNumberReader linhaLeitura = new LineNumberReader(new FileReader(arquivoLeitura));
linhaLeitura.skip(arquivoLeitura.length());
int qtdLinha = linhaLeitura.getLineNumber() + 1;
BufferedReader leitor = new BufferedReader(new InputStreamReader(new FileInputStream(getArquivo())));
String linha = null;
List<TotalIndicios> listaTotalDeIndicios = new ArrayList<TotalIndicios>();
List<IndiciosEntity> listaIndiciosEntity = new ArrayList<IndiciosEntity>();
for (int indiceDeIndicios = 1; indiceDeIndicios <= qtdLinha; indiceDeIndicios++) {
linha = leitor.readLine();
String[] dadosCSV = linha.split(VIRGULA);
//vai fazer alguma coisa......
}
what is the " maximum number of positions"? are would just split the line values and take the Count from that?
– Ricardo Pontual
I found the number of positions, I found this coddgo int numberPositions = dadosCSV.length .
– wladyband
yes it was that, the variable
dadosCSV
has the array of line contents obtained after thesplit
, lenght shows exactly how many items are in the array :)– Ricardo Pontual