-
-
Save uncoded-ro/0dd8d5274ed053295ab61e98d91dda05 to your computer and use it in GitHub Desktop.
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
package ro.virtualcampus.copy; | |
import java.io.FileReader; | |
import java.io.FileWriter; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
public class CharStream { | |
public static void main(String[] args) { | |
FileReader fin = null; | |
FileWriter fout = null; | |
try { | |
fin = new FileReader("in.txt"); | |
fout = new FileWriter("out.txt"); | |
int c; | |
while ((c = fin.read()) != -1) { | |
fout.write((char) c); | |
} | |
System.out.println("proces finalizat cu succes"); | |
} catch (FileNotFoundException e) { | |
System.out.println("fisier inexistent"); | |
e.printStackTrace(); | |
} catch (IOException e) { | |
System.out.println("eroare citire"); | |
e.printStackTrace(); | |
} finally { | |
try { | |
if (fin != null) | |
fin.close(); | |
if (fout != null) | |
fout.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment