Aplicatie Java Cu Fisiere

  • Uploaded by: deianira
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Aplicatie Java Cu Fisiere as PDF for free.

More details

  • Words: 142
  • Pages: 2
//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"); } } }

Related Documents


More Documents from "deianira"

May 2020 18
Prefixoide
December 2019 12
Kirac-siyah Gece Lyrics
December 2019 17