All pastes #272079 Raw Edit

Unnamed

public java v1 · immutable
·published 2006-12-08 18:33 UTC
rendered paste body
/* * @author Tiago Palhota ( Gurzi ) * * Created on December 8, 2006, 4:37 PM * ############################################ *    Objectivo: * * * ############################################ * *--------------------------------------------- *  USE THIS FOR FREE . BUT FIRST LEARN *--------------------------------------------- */package pt.tiago.exercicios;import java.io.*;public class teste{    public static void main(String[] args)    {         Reader dataIn = null;         private int lineCount = 0;         private static final int EOF = -1;         String ficheiro = "tiago.txt";                try        {            dataIn =  new BufferedReader(new FileReader(ficheiro));            int ch; // recebe o caracter atraves do metodo read() de Reader            boolean wasFinalLine =  false;                        while((ch = dataIn.read() ) != EOF)            {                if(ch == '\n')                    ++lineCount;                else                {                    ++lineCount;                    wasFinalLine = true;                }            }                                }        catch(IOException e)        {            System.err.println("Falhou");        }                                    if(dataIn != null)        {            System.out.println("Foram Encontradas " +lineCount +"linhas");        }    }}