public static void downloadFile(String path, String url) throws IOException {  
        DefaultHttpClient client = null;  
        try {  
            // 创建HttpClient对象  
            client = new DefaultHttpClient();  
            // 获得HttpGet对象  
            HttpGet httpGet = new HttpGet(url); 
            // 发送请求获得返回结果  
            HttpResponse response = client.execute(httpGet);  
            // 如果成功  
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {  
                byte[] result = EntityUtils.toByteArray(response.getEntity());  
                BufferedOutputStream bw = null;  
                try {  
                    // 创建文件对象  
                    File f = new File(path);  
                    // 创建文件路径  
                    if (!f.getParentFile().exists())  
                        f.getParentFile().mkdirs();  
                    // 写入文件  
                    bw = new BufferedOutputStream(new FileOutputStream(path));  
                    bw.write(result);  
                } catch (Exception e) {  
                } finally {  
                    try {  
                        if (bw != null)  
                            bw.close();  
                    } catch (Exception e) {
                    	e.printStackTrace();
                    }  
                }  
            }
        } catch (ClientProtocolException e) {  
            throw e;  
        } catch (IOException e) {  
            throw e;  
        } finally {  
            try {  
                client.getConnectionManager().shutdown();  
            } catch (Exception e) { 
            	e.printStackTrace();
            }  
        }  
    }