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 8512711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:21:25+00:00 2026-06-11T04:21:25+00:00

After reading this: Code for download video from Youtube on Java, Android I found

  • 0

After reading this: Code for download video from Youtube on Java, Android

I found a way the obtain the youtube download link which is similar to this:
http://o-o—preferred—lax02s10—v9—lscache4.c.youtube.com/videoplayback?upn=7XKwMrZklvQ&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=903903%

I tried to download the video using

    public void DownloadFromUrl(String DownloadUrl, String fileName) {
    Log.i("DownloadFromUrl","DownloadFromUrl"+DownloadUrl);

       try {
               File root = android.os.Environment.getExternalStorageDirectory();               

               File dir = new File (root.getAbsolutePath() + "/youlike");
               if(dir.exists()==false) {
                    dir.mkdirs();
               }

               URL url = new URL(DownloadUrl); //you can write here any link
               File file = new File(dir, fileName);

               long startTime = System.currentTimeMillis();
               Log.d("DownloadManager", "download begining");
               Log.d("DownloadManager", "download url:" + url);
               Log.d("DownloadManager", "downloaded file name:" + fileName);


               /* Open a connection to that URL. */
               URLConnection ucon = url.openConnection();
               Log.i("URLConnection","URLConnection Succeed");

               /*
                * Define InputStreams to read from the URLConnection.
                */ 
               InputStream is = ucon.getInputStream();
               BufferedInputStream bis = new BufferedInputStream(is);
               Log.i("BufferedInputStream","BufferedInputStream Succeed");

               /*
                * Read bytes to the Buffer until there is nothing more to read(-1).
                */
               ByteArrayBuffer baf = new ByteArrayBuffer(5000);
               int current = 0;
               while ((current = bis.read()) != -1) {
                  baf.append((byte) current);
                  Log.i("ByteArrayBuffer","ByteArrayBuffer Succeed");

               }


               /* Convert the Bytes read to a String. */
               FileOutputStream fos = new FileOutputStream(file);
               Log.i("FileOutputStream","FileOutputStream initialized");
               fos.write(baf.toByteArray());
               Log.i("fos.write(baf.toByteArray());","fos.write(baf.toByteArray()); initialized");
               fos.flush();
               fos.close();
               Log.d("DownloadManager", "download ready in" + ((System.currentTimeMillis() - startTime) / 1000) + " sec");

       } catch (IOException e) {
           Log.d("DownloadManager", "Error: " + e);
       }

    }

But it returns an error message to me: java.io.FileNotFoundException
I tested the url and I am sure that it works. Can anyone tell me what the problem is?

  • 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-11T04:21:26+00:00Added an answer on June 11, 2026 at 4:21 am

    You should encode you youtube download link before open the http connection

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

Sidebar

Related Questions

i was reading this code, where setRegions is called after RootViewController is released :
After reading this article, it makes sense to rebase to gather changes from the
After reading this question , i saw the answer by Naveen containing a link
I am coming back from after reading this c-faq question I am totaly confused
After reading this article http://camendesign.com/code/developpeurs_sans_frontieres I have decided to follow what it says and
The fallowing clause is taken from jetbrains.net After reading this and some other articles
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
After reading this article I don't have a clear answer: http://palizine.plynt.com/issues/2010Oct/bypass-xss-filters/ Will browsers interpret
After reading this post I kinda felt in the same position as the guy
After reading this article on thedailywtf.com, I'm not sure that I really got the

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.