Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File text = new File("Fahrzeug.txt");
- FileWriter writer;
- Nummer14Auto auto = new Nummer14Auto("Grün", 4, true);
- Nummer14Fahrrad fahrrad = new Nummer14Fahrrad("Pink", 2, true);
- try {
- writer = new FileWriter(text);
- writer.write(auto.toString() + "\n");
- writer.write(fahrrad.toString());
- writer.flush();
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- if(text.exists()){
- try {
- Scanner sc = new Scanner(text);
- while(sc.hasNext()){
- System.out.println(sc.next() + " ");
- }
- sc.close();
- } catch (FileNotFoundException e1) {
- e1.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement