Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created January 12, 2020 07:07
Show Gist options
  • Save uncoded-ro/0dd8d5274ed053295ab61e98d91dda05 to your computer and use it in GitHub Desktop.
Save uncoded-ro/0dd8d5274ed053295ab61e98d91dda05 to your computer and use it in GitHub Desktop.
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