Skip to content

Instantly share code, notes, and snippets.

@golenishchev
Created January 4, 2016 17:09
Show Gist options
  • Save golenishchev/08afa356326a6d2b0da7 to your computer and use it in GitHub Desktop.
Save golenishchev/08afa356326a6d2b0da7 to your computer and use it in GitHub Desktop.
Lesson 14. BufferedReader, PrintWriter, FileReader, FileWriter
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