import java.util.*; /* Programme : numéroter les lignes */ class Nl { public static void main(String[] args) throws java.io.IOException { int c; boolean bol = true; // début de ligne (Beginning Of Line) int nl = 0; // numéro de ligne while ((c = System.in.read()) != -1) { if (bol) { nl++; // System.out.printf permet de faire des sorties // formatées (par exemple, ici, afficher un entier // avec une largeur donnée) System.out.printf("%6d ", nl); } System.out.write(c); bol = (c == '\n'); } System.out.flush(); } }