mihainan

Problema 1 - Lab05

Nov 4th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. package Lab05;
  2.  
  3. import java.io.*;
  4.  
  5. /**
  6.  *
  7.  * @author Nan Mihai
  8.  */
  9. public class Prob1 {
  10.     public static void main(String arg[]) throws IOException {
  11.         String nume;
  12.         String cale;
  13.         cale = "H:\\Anul II\\Programare orientata pe obiecte\\Java\\src\\Lab05";
  14.         nume = cale + "\\" + "fisier.txt";
  15.         try (LineNumberReader raf = new LineNumberReader(new FileReader(nume))) {
  16.             String s;
  17.             while((s = raf.readLine()) != null) {
  18.                 System.out.println(raf.getLineNumber() + "  " + s);
  19.             }
  20.         raf.close();
  21.         }
  22.         catch(FileNotFoundException e) {
  23.             System.out.println("Fisierul nu exista!");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment