Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package genid;
- import java.io.*;
- import javax.swing.JOptionPane;
- public class Contatore extends Genera {
- LineNumberReader counter;
- public int ContaRighe() { // metodo per contare le righe di un file
- try {
- counter = new LineNumberReader(new FileReader(TextArray[i]));
- while (counter.readLine() != null) {
- ++N_Righe;
- }
- } catch (FileNotFoundException x) {
- JOptionPane.showMessageDialog(null, "File non trovato!", "ERRORE", JOptionPane.ERROR_MESSAGE);
- } catch (IOException x) {
- JOptionPane.showMessageDialog(null, "Problemi tecnici.", "ERRORE", JOptionPane.ERROR_MESSAGE);
- } finally {
- try {
- if (i == TextArray.length) {
- counter.close(); // chiude la risorsa
- }
- } catch (IOException x) {
- JOptionPane.showMessageDialog(null, "Problemi tecnici.", "ERRORE", JOptionPane.ERROR_MESSAGE);
- }
- }
- return N_Righe;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment