Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException{
- Scanner sc = new Scanner(System.in);
- String imie = sc.nextLine();
- String nazwisko = sc.nextLine();
- zapiszPlik(imie,nazwisko);
- czytanie();
- }
- public static void zapiszPlik(String imie, String nazwisko) throws IOException{
- BufferedWriter bw = new BufferedWriter(new FileWriter("D:/tekst.txt"));
- bw.write(imie);
- bw.newLine();
- bw.write(nazwisko);
- bw.close();
- }
- public static void czytanie() throws FileNotFoundException, IOException{
- BufferedReader br = new BufferedReader(new FileReader("D:/tekst.txt"));
- for(int i =0;i<2;i++){
- System.out.println(br.readLine());
- }
- br.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment