blooming8

Gen ID - Conta

Jun 2nd, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. package genid;
  2.  
  3. import java.io.*;
  4. import javax.swing.JOptionPane;
  5.  
  6. public class Contatore extends Genera {
  7.     LineNumberReader counter;
  8.  
  9.     public int ContaRighe() { // metodo per contare le righe di un file
  10.         try {
  11.             counter = new LineNumberReader(new FileReader(TextArray[i]));
  12.             while (counter.readLine() != null) {
  13.                 ++N_Righe;
  14.             }
  15.         } catch (FileNotFoundException x) {
  16.             JOptionPane.showMessageDialog(null, "File non trovato!", "ERRORE", JOptionPane.ERROR_MESSAGE);
  17.         } catch (IOException x) {
  18.             JOptionPane.showMessageDialog(null, "Problemi tecnici.", "ERRORE", JOptionPane.ERROR_MESSAGE);
  19.         } finally {
  20.             try {
  21.                 if (i == TextArray.length) {
  22.                     counter.close(); // chiude la risorsa
  23.                 }
  24.             } catch (IOException x) {
  25.                 JOptionPane.showMessageDialog(null, "Problemi tecnici.", "ERRORE", JOptionPane.ERROR_MESSAGE);
  26.             }
  27.         }
  28.         return N_Righe;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment