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 wejsciowkastrumienie2;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.LineNumberReader;
- import java.util.Scanner;
- /**
- *
- * @author lenovo
- */
- public class WejsciowkaStrumienie2 {
- public static void main(String[] args) throws IOException
- {
- BufferedReader czytanie = null;
- BufferedWriter zapisywanie = null;
- LineNumberReader w= null;
- String nazwa;
- Scanner sc = new Scanner(System.in);
- try
- {
- System.out.println("Podaj nazwe pliku: ");
- nazwa = sc.nextLine();
- System.out.println(nazwa);
- czytanie = new BufferedReader (new FileReader(nazwa));
- zapisywanie = new BufferedWriter (new FileWriter(""));
- w = new LineNumberReader(czytanie);
- i = w.getLineNumber();
- }
- catch (IOException ex)
- {
- System.err.println("nie moge odpalic pliku");
- }
- try
- {
- String line = "";
- while(!"quit".equals(line))
- {
- System.out.println( "podaj co chcesz zapisac do pliku: ");
- line = sc.nextLine();
- zapisywanie.write(line);
- zapisywanie.newLine();
- System.out.println(line);
- }
- }
- catch(IOException e)
- {
- System.out.println("Błąd");
- }
- finally
- {if (czytanie!=null) czytanie.close();
- if(zapisywanie!=null) zapisywanie.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement