package com.saki.plugin.dictionary;

import java.io.File;
import java.io.FileOutputStream;

import android.os.Environment;

import com.saki.http.Http;

public class DownloadThread extends Thread {
    private String path;
    private String url;

    public DownloadThread(String path, String url) {
        this.path = path;
        this.url = url;
        start();
    }

    @Override
    public void run() {
        try {
            File f = new File(Environment.getExternalStorageDirectory() + path);
            if (!f.exists()) {
                f.getParentFile().mkdirs();
                f.createNewFile();
            }
            FileOutputStream out = new FileOutputStream(f);
            byte[] bin = new Http().call("GET",url,null);
            out.write(bin);
            out.flush();
            out.close();
        } catch (Exception e) {
        }
    }
}
