public class A {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
File file = new File("bin/exercise.txt");
File file2 = new File("bin/exercise2.txt");
fis = new FileInputStream(file);
fos= new FileOutputStream(file2);
byte[] b = new byte[5];
int num=0;
while ((num=fis.read(b)) != -1) {
fos.write(b, 0, num);
}
} catch (Exception e) {
e.printStackTrace();
}
finally
{
try {
if(fis!=null){
fis.close();
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if(fos!=null){
fos.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
} |