Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8603587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:21:33+00:00 2026-06-12T02:21:33+00:00

I am getting a url from server & i want to save video in

  • 0

I am getting a url from server & i want to save video in my android htc device .
I am getting Some errors:—–
java.io.FileNotFoundException: /mnt/sdcard/543b8417-6e67-4755-8c68-b93373f9d9e2.wmv (Permission denied)
& address family not supported.
I have given all permission in menifest file.
My code is :-
videoUrl = “http://125.63.71.222/fliptest/uservideo/543b8417-6e67-4755-8c68-b93373f9d9e2.wmv”;

    String LocalFilePath = videoUrl.substring(
            videoUrl.lastIndexOf("/") + 1, videoUrl.length());
    File dire = new File(android.os.Environment.getExternalStorageDirectory(), LocalFilePath);






        int bytesread = 0;
        byte[] bytes = new byte[8192];
        InputStream strm = null;
        HttpResponse response = null;
        HttpEntity entity = null;
        String LocalFile = null;
        FileOutputStream foStream;
        BufferedOutputStream writer = null;
        try {
            DefaultHttpClient httpclient = new DefaultHttpClient();
            videoUrl = videoUrl.replace(" ", "%20");
            HttpGet httpget = new HttpGet(videoUrl);

            response = httpclient.execute(httpget);

            entity = response.getEntity();
            strm = entity.getContent();







            LocalFile = android.os.Environment.getExternalStorageDirectory() + LocalFilePath;
            //directory = null;
            foStream = new FileOutputStream(dire);
            writer = new BufferedOutputStream(foStream);
            do {
                bytesread = strm.read(bytes, 0, bytes.length);
                if (bytesread > 0) {
                    writer.write(bytes, 0, bytesread);
                    writer.flush();
                }
            } while (bytesread > 0);

            writer.close();
            foStream.close();

            strm.close();
            return;

        } catch (Exception e) {
        //  dire.delete();              
            e.printStackTrace();

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:21:35+00:00Added an answer on June 12, 2026 at 2:21 am

    I would slightly modify your code:

    String videoUrl = "http://125.63.71.222/fliptest/uservideo/543b8417-6e67-4755-8c68-b93373f9d9e2.wmv";
    String LocalFilePath = videoUrl.substring(videoUrl.lastIndexOf("/") + 1, videoUrl.length());
    File dire = new File(android.os.Environment.getExternalStorageDirectory(), LocalFilePath);
    
    int bytesread = -1; // i would change it to -1
    byte[] bytes = new byte[8192];
    InputStream strm = null;
    FileOutputStream foStream;
    
    try {
        videoUrl = videoUrl.replace(" ", "%20");
        URL url = new URL(videoUrl);
        URLConnection connection = url.openConnection();
        connection.connect();
    
        strm = new BufferedInputStream(url.openStream());
        foStream = new FileOutputStream(dire);
    
        //typical pattern for reading
        while ((bytesread = strm.read(bytes)) != -1) {
            foStream.write(bytes, 0, bytesread);
        }
    
        foStream.flush();
        foStream.close();
        strm.close();
    
    } catch (Exception e) {
       ...
    }
    

    You need two permissions to run this code – you’ve already mentioned you have them but quick reminder:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    And don’t forget to run this task asynchronously.

    Best Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im getting a JSON from a server, and when I type the url into
I am getting some HTML from server and showing in Textview. The HTML have
I am getting a URL from server and trying to load the URL in
i am creating rss reader application with php.it is basicly getting rss url's from
im having trouble getting a string (containing a URL) from one activity to another.
After removing hash from URL using window.location.hash='' page getting reloaded in firefox. EDIT Example:
I there a way to getting picture(image) from URL without downloading? I use the
I am getting the response from a URL and trying to create pdf from
I'm tryinig to load a file from a web server with a request URL
I'm getting a response from a server using boost::asio. The result is stored in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.