Created
January 4, 2016 17:09
-
-
Save golenishchev/08afa356326a6d2b0da7 to your computer and use it in GitHub Desktop.
Lesson 14. BufferedReader, PrintWriter, FileReader, FileWriter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileReader; | |
import java.io.FileWriter; | |
import java.io.BufferedReader; | |
import java.io.PrintWriter; | |
import java.io.IOException; | |
public class FileManager { | |
public static void main(String[] args) throws Exception { | |
try ( | |
BufferedReader br = new BufferedReader(new FileReader("first.txt")); | |
PrintWriter pw = new PrintWriter(new FileWriter("second.txt")); | |
) { | |
int line; | |
while ((line = br.read()) != -1) { | |
pw.write(line); | |
} | |
} | |
System.out.println("Check your file second.txt, all done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment