Skip to content

Instantly share code, notes, and snippets.

@leandrogilvalle
Last active January 10, 2023 00:10
Show Gist options
  • Save leandrogilvalle/7f30c0a276e28d8d9dc9dd06155b324d to your computer and use it in GitHub Desktop.
Save leandrogilvalle/7f30c0a276e28d8d9dc9dd06155b324d to your computer and use it in GitHub Desktop.
Java - Mostrar a quantidade de linhas no arquivo
public void imprimirQuantidadeLinhasArquivo() throws IOException {
File arquivoLeitura = new File("arquivo.txt");
LineNumberReader linhaLeitura = new LineNumberReader(new FileReader(arquivoLeitura));
linhaLeitura.skip(arquivoLeitura.length());
int qtdLinha = linhaLeitura.getLineNumber();
System.out.println("Quantidade de Linhas no arquivo: " + qtdLinha);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment