Copy File Thread
//package eecs.umich.threegtest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import android.os.Environment;
import android.util.Log;
public class CopyFile extends Thread {
String mSrc;
String mDet;
CopyFile(String Filename1) {
mSrc = Filename1;
mDet = "UMLogger.txt";
}
public void run() {
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()) {
File logfile = new File(root, mDet);
FileOutputStream out = new FileOutputStream(logfile);
FileInputStream fin = new FileInputStream(mSrc);
byte[] buf = new byte[1024];
int len;
while ((len = fin.read(buf)) > 0) {
out.write(buf, 0, len);
Log.v("check", "length is " + len);
}
fin.close();
out.close();
}
} catch (IOException e) {
Log.e("check", "Could not write file " + e.getMessage());
}
}
}
Related examples in the same category