All pastes #2075829 Raw Edit

Miscellany

public text v1 · immutable
#2075829 ·published 2011-06-06 23:35 UTC
rendered paste body
import static pt.ua.prog.WIO.*;
import java.io.*;

class ex4Teste
{

  public static void main(String [] args) throws IOException
  {
	BufferedReader br;
	BufferedWriter bw;

	String inFile = "input.txt";
	String outFile = "output.txt";
	
	try
	{
		br = new BufferedReader(new FileReader(inFile));
	}
	catch(Exception e)
	{
		println("Erro a abrir ficheiro de input");
		return;
	}

	try
	{
		bw = new BufferedWriter(new FileWriter(outFile));
	}
	catch(Exception e)
	{
		println("Erro a abrir ficheiro de output");
		return;
	}

	int tiragens = 0;
	String s;

	try
	{
		do
		{
			s = br.readLine();
			if(s!=null)
				tiragens++;
		}while(s!=null);		
	
		bw.write("O jornal teve " + tiragens + " tiragens\n");
	}
	catch(Exception e)
	{
		println("Erro a ler/escrever");
	}

	br.close();
	bw.close();
  }


}