mihainan

Prob 1 - Lab05

Nov 5th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package Lab0501;
  7.  
  8. import java.io.*;
  9.  
  10. /**
  11.  *
  12.  * @author Nan Mihai
  13.  */
  14. public class Prob1 {
  15.     public static void main(String args[]) throws IOException {
  16.         String nume;
  17.         String cale;
  18.         cale = "H:\\Anul II\\Programare orientata pe obiecte\\Java\\Lab1\\JavaApplication1\\src\\Lab0501";
  19.         nume = cale + "\\" + "fisier.txt";
  20.         try (LineNumberReader raf = new LineNumberReader(new FileReader(nume))) {
  21.             String s[] = new String[100], text;
  22.             int i = 0, j, n;
  23.             while((text = raf.readLine()) != null) {
  24.                 s[i] = text;
  25.                 i++;
  26.             }
  27.             n = i;
  28.             for(i = n-1; i >= 0; i--) {
  29.                 for(j = 0; j <= i; j++) {
  30.                     System.out.println(s[i]);
  31.                 }
  32.             }
  33.             raf.close();
  34.         }
  35.         catch(FileNotFoundException e) {
  36.             System.out.println("Fisierul nu exista!");
  37.         }
  38.     }
  39.    
  40.     public void variantaRecursiva(String nume) {
  41.        
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment