For copy one file to another one, just run next code:


InputStream inStream = null;
OutputStream outStream = null;

try{

File firstfile =new File("firstfile.png");
File secondfile =new File("secondfile.txt");

inStream = new FileInputStream(firstfile);
outStream = new FileOutputStream(secondfile);

byte[] buffer = new byte[1024];

int length;

while ((length = inStream.read(buffer)) > 0){

outStream.write(buffer, 0, length);

}

inStream.close();
outStream.close();

}catch(IOException e){
e.printStackTrace();
}