Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save josivantarcio/5b1e4cb84b287d7fec80c8885366e998 to your computer and use it in GitHub Desktop.
Save josivantarcio/5b1e4cb84b287d7fec80c8885366e998 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