All pastes #673363 Raw Edit

Untitled

public text v1 · immutable
#673363 ·published 2007-08-28 10:41 UTC
rendered paste body
import java.io.*;


public class TekstitiedostonLukija {
  static File tiedosto;
  static BufferedReader syottotdsto = null;

  public static void main(String[] args) {
  
  
    
    if (args.length != 2) {
      System.out.println("Anna vain kaksi parametria!");
      System.out.println("1. Parametri kertoo luettavan tiedoston.");
      System.out.println("2. Parametri kerralla luettavien rivien lukumäärän (0 on vakio).");
    }
    else {
      int lkm = new Integer(args[1]);
      File tdsto = new File(args[0]);
      
      tiedosto = tdsto;
      try {
        syottotdsto = new BufferedReader(new FileReader(tiedosto));
      }
      catch (FileNotFoundException e2) {
        System.out.println("Tiedostoa " + tiedosto + " ei löytynyt!");
      }
      catch (NumberFormatException e3) {
        System.out.println("2. Parametri ei ollut kokonaisluku!");
      }
        
      TekstitiedostonIteroija teksti = new TekstitiedostonIteroija(tdsto, lkm);
      teksti.hasNext();
    }
      
}
}