package hoidmine; import java.util.*; import java.io.*; import java.util.logging.*; public class Hoidla { String failinimi; List arvud=new ArrayList(); Logger logija; public Hoidla(String fnimi){ try{ logija=Logger.getLogger("Hoidla"); FileHandler fh=new FileHandler("teated.log"); logija.addHandler(fh); logija.setLevel(Level.INFO); logija.log(Level.INFO, "Loodi hoidla"); failinimi=fnimi; File f=new File(failinimi); if(f.exists()){f.delete();} f.createNewFile(); } catch(Exception ex){ logija.log(Level.WARNING, ex.getMessage()); //throw new RuntimeException(ex); } } public void lisa(double arv){ try{ PrintWriter pw=new PrintWriter(new FileWriter(failinimi, true)); pw.println(arv); pw.close(); } catch (Exception ex){ logija.log(Level.WARNING, ex.getMessage()); } arvud.add(arv); } public int kogus(){ return arvud.size(); } }