Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lab05;
- import java.io.*;
- /**
- *
- * @author Nan Mihai
- */
- public class Prob1 {
- public static void main(String arg[]) throws IOException {
- String nume;
- String cale;
- cale = "H:\\Anul II\\Programare orientata pe obiecte\\Java\\src\\Lab05";
- nume = cale + "\\" + "fisier.txt";
- try (LineNumberReader raf = new LineNumberReader(new FileReader(nume))) {
- String s;
- while((s = raf.readLine()) != null) {
- System.out.println(raf.getLineNumber() + " " + s);
- }
- raf.close();
- }
- catch(FileNotFoundException e) {
- System.out.println("Fisierul nu exista!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment