I wrote this program to copy one pdf file to other but I'm getting curupt fiel in o/p for .txt files this code is working fine.
code:
public class FileCopy {
public static void main(String args[]) {
try {
FileInputStream fs = new FileInputStream("C:\\dev1.pdf");
byte b;
FileOutputStream os = new FileOutputStream("C:\\dev2.pdf");
while ((b = (byte) fs.read()) != -1) {
os.write(b);
}
os.close();
fs.close();
} catch (Exception E) {
E.printStackTrace();
}
}
}