Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileWriter;
- import java.util.*;
- public class s17014_p03 {
- public static void main(String[] args) throws FileNotFoundException {
- // odczyt danych z plikow do listy
- ArrayList<Osoba> listaOsob = new ArrayList<>();
- File file = new File("dane01.txt");
- try {
- Scanner input = new Scanner(file);
- while (input.hasNext()) {
- String num = input.nextLine();
- System.out.println(num);
- listaOsob.add(new Osoba(num));
- }
- }
- catch (FileNotFoundException e) {
- System.err.format("File Does Not Exist\n");
- }
- File file1 = new File("dane02.txt");
- try {
- Scanner input = new Scanner(file1);
- while (input.hasNext()) {
- String num = input.nextLine();
- System.out.println(num);
- listaOsob.add(new Osoba(num));
- }
- }
- catch (FileNotFoundException e) {
- System.err.format("File Does Not Exist\n");
- }
- // zapisywanie do pliku
- try{
- FileWriter fw=new FileWriter("sortEska.txt");
- fw.write("Test");
- fw.close();
- }catch(Exception e){System.out.println(e);}
- System.out.println("Success...");
- try{
- FileWriter fw=new FileWriter("sortName.txt");
- fw.write("Test");
- fw.close();
- }catch(Exception e){System.out.println(e);}
- System.out.println("Success...");
- }
- }
- class Osoba {
- private String imie;
- private String nazwisko;
- private int rokUrodzenia;
- public Osoba(String input) {
- String[] splitString = input.split(" ");
- this.imie = splitString[1];
- this.nazwisko = splitString[2];
- this.rokUrodzenia = Integer.parseInt(splitString[3]);
- }
- }
- //class Student extends Osoba{
- //
- // private String numerIndexu;
- //
- // super();
- //
- // public Student(String input){
- //
- // String[] splitString = input.split(" ");
- // this.numerIndexu = splitString[0];
- //
- // }
- //
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement