Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void downloadVideo(String Video_URL) {
- try {
- url = new URL(Video_URL);
- HttpURLConnection c = (HttpURLConnection) url.openConnection();
- c.setRequestMethod("GET");
- c.setDoOutput(true);
- c.connect();
- PATH = Environment.getExternalStorageDirectory()
- + "/urpath/";
- Log.d("", "the path to store : " + PATH);
- File file = new File(PATH);
- file.mkdirs();
- File outputFile = new File(file, fileName);
- FileOutputStream fos = new FileOutputStream(outputFile);
- InputStream is = c.getInputStream();
- byte[] buffer = new byte[1024];
- int len1 = 0;
- while ((len1 = is.read(buffer)) != -1) {
- fos.write(buffer, 0, len1);
- }
- fos.close();
- is.close();
- mHandler.sendEmptyMessage(DOWNLOADED_SUCCESS);
- } catch (Exception e) {
- mHandler.sendEmptyMessage(DOWNLOADED_FAILED);
- Log.d("TAG", " downloadVideo exception " + e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement