Created
January 5, 2016 17:38
-
-
Save golenishchev/17a9e9f57a0250aafea8 to your computer and use it in GitHub Desktop.
Lesson14v2
This file contains 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 copyFile(String firstFile, String secondFile) throws Exception { | |
try ( | |
BufferedReader br = new BufferedReader(new FileReader(firstFile)); | |
PrintWriter pw = new PrintWriter(new FileWriter(secondFile)); | |
) { | |
int line; | |
while ((line = br.read()) != -1) { | |
pw.write(line); | |
} | |
} | |
System.out.println("All done"); | |
} | |
public static void main(String[] args) throws Exception { | |
String firstFile = "first.txt"; | |
String secondFile = "second3.txt"; | |
copyFile(firstFile,secondFile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment