Android examples for File Input Output:Copy File
copy File from one path to another path
/*/*from w w w.jav a 2 s. co m*/ * Copyright (c) 2014 Yu Zhiqiang * Open source license: The MIT License */ //package com.java2s; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static void copyFile(String from, String to) throws IOException { FileInputStream fileInputStream = new FileInputStream(from); FileOutputStream fileOutputStream = new FileOutputStream(to); // Transfer bytes from the fileInputStream to the fileOutputStream byte[] buffer = new byte[1024 * 1024]; int length; while ((length = fileInputStream.read(buffer)) > 0) { fileOutputStream.write(buffer, 0, length); } // Close the streams fileInputStream.close(); fileOutputStream.close(); } }