Guest User

Untitled

a guest
Jan 3rd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public static void main(String[] args) throws IOException{
  2. Scanner sc = new Scanner(System.in);
  3. String imie = sc.nextLine();
  4. String nazwisko = sc.nextLine();
  5.  
  6. zapiszPlik(imie,nazwisko);
  7. czytanie();
  8.  
  9. }
  10.  
  11. public static void zapiszPlik(String imie, String nazwisko) throws IOException{
  12. BufferedWriter bw = new BufferedWriter(new FileWriter("D:/tekst.txt"));
  13. bw.write(imie);
  14. bw.newLine();
  15. bw.write(nazwisko);
  16. bw.close();
  17. }
  18. public static void czytanie() throws FileNotFoundException, IOException{
  19. BufferedReader br = new BufferedReader(new FileReader("D:/tekst.txt"));
  20. for(int i =0;i<2;i++){
  21. System.out.println(br.readLine());
  22. }
  23. br.close();
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment