Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication19;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.StringTokenizer;
- /**
- *
- * @author student
- */
- public class JavaApplication19 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int l = 0;
- String linie = null;
- PrintWriter fout = null;
- BufferedReader fin = null;
- String nume,prenume;
- double nota;
- int prezenta;
- try {
- fout = new PrintWriter(new FileWriter("linefile.txt"));
- fout.println("Pop,Vasile");
- fout.println("4,12");
- fout.close();
- fin = new BufferedReader(new FileReader("linefile.txt"));
- linie = fin.readLine();
- System.out.println("S-a citit linia: " + linie);
- StringTokenizer t = new StringTokenizer(linie, ","); //extragerea simbolurilor pe baza separatorului ,
- nume = t.nextToken();
- prenume = t.nextToken();
- linie = fin.readLine();
- System.out.println("S-a citit linia: " + linie);
- t = new StringTokenizer(linie, ",");
- nota = Double.parseDouble(t.nextToken());
- prezenta = Integer.parseInt(t.nextToken());
- System.out.println(nume +" "+ prenume +" nota:"+ nota +" prezente:"+ prezenta);
- fin.close();
- } catch (IOException e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement