import java.io.*; import java.util.*; public class Test{ public Test(){} public int lire(){ int cpt = 0; try { String ligne; BufferedReader in = new BufferedReader(new FileReader("D:/USER/Test.java")); while (in.ready()) { System.out.println(in.readLine()); cpt++; } } catch(Exception e){System.out.println (e.getMessage());} return cpt; } public static void main(String[] args){ Test test = new Test(); System.out.println("Il y a " + test.lire() + " lignes dans ce texte."); } }