-
-
Save uncoded-ro/387aa8e2c4999badec343a427d42b110 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.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
public class ByteStream { | |
public static void main(String[] args) { | |
FileInputStream fin = null; | |
FileOutputStream fout = null; | |
try { | |
fin = new FileInputStream("in.png"); | |
fout = new FileOutputStream("out.png"); | |
int c; | |
while ((c = fin.read()) != -1) { | |
fout.write((byte)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