P. 1
Aplicatie Java cu fisiere

Aplicatie Java cu fisiere

|Views: 722|Likes:
Published by deianira
program java care citeste de la tastatura numere si le scrie intr-un fisier;Dupa ce datele au fost scrise,cu un parser StreamTokenizer le afiseaza la terminal
program java care citeste de la tastatura numere si le scrie intr-un fisier;Dupa ce datele au fost scrise,cu un parser StreamTokenizer le afiseaza la terminal

More info:

Categories:Types, School Work
Published by: deianira on Mar 28, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

06/06/2013

pdf

//Aplicatie Java cu fluxuri de intrare si iesire //program care citeste numere de la tastatura si le memoreaza intr-un fisier iesire.

txt //apoi,folosind clasa StreamTokenizer parsam datele si le afisam la terminal import java.io.*; import java.lang.*; public class Aplicatie1 { private BufferedReader tastatura; public static void main (String[] args) { Aplicatie1 a=new Aplicatie1(); a.executa(); a.executa1(); } public void executa() { try { //declaram 2 fisiere si un buffer pt tastatura FileWriter f1=new FileWriter("iesire.txt"); //crearea unui flux de intrare dintr-un fisier care va fi parsat de un StreamTokenizer String vid=" "; tastatura=new BufferedReader(new InputStreamReader(System.in),1); for (int i=1;i<10;i++) { System.out.println("dati un numar:"); String sir=tastatura.readLine(); f1.write(sir); f1.write(vid); // f1.write(Integer.valueOf(sir)); //goleste bufferul de iesire in fisier // String linie=tastatura.readLine(); } f1.close(); } catch(IOException e) { System.out.println("eroare"); }

} public void executa1() { try{ StreamTokenizer p=new StreamTokenizer(new FileReader("iesire.txt")); p.eolIsSignificant(false); while(p.nextToken()!=p.TT_EOF) if (p.ttype==p.TT_NUMBER) System.out.println("numar:"+p.nval);}catch(IOException e){ System.out.println("eroare"); } } }

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->