Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package a_Zadania.d_Dzien_4.b_Pliki;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Scanner;
- public class Main1 {
- public static void main(String[] args) {
- System.out.println("Podaj linie:");
- Scanner scan = new Scanner(System.in);
- FileWriter out;
- try {
- out = new FileWriter("tekst3.txt", true); // true dopisuje; false nadpisze plik.
- while (scan.hasNextLine()) {
- //String s = scan.next(); // słowo po słowie
- String s = scan.nextLine(); // linia po linii
- if (s.equals("quit")) {
- System.out.println("Exit");
- break;
- } else {
- out.append(s + "\n");
- }
- }
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement