URL Content Download

Hi
i'd like to get data from an url... i used this code but doesn't works with all websites....
public byte[] getData(String url) throws Exception {
URL myUrl = new URL(url);
URLConnection conn = myUrl.openConnection();
     byte[] urldata;
     byte[] tmpdata;
URL_LENGTH = conn.getContentLength();
// Some websites release a connection length equals to -1
     if(URL_LENGTH!=-1)
urldata = new byte[URL_LENGTH];
else urldata = new byte[100000];
     InputStream input = conn.getInputStream();
// puts data in the array to return
     input.read(urldata);
     input.close();
FileOutputStream f = new FileOutputStream(new File("/myFile.html"));
f.write(urldata);
f.close();
     return urldata;
This code works only with a few of websites...does anyone can help me ?!?!
PLease

Here is a little class I use to copy files (either from the internet or from a hard drive). From the command line try:
java UFile http://developer.java.sun.com temp.txt
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
public class UFile
     public static void main(String arg[])
      throws IOException
          InputStream is = getInputStream( arg[0] );
          OutputStream os = getOutputStream( arg[1] );
          System.out.println( UFile.copy(is, os) + " bytes copied" );
          System.exit(0);
     public static InputStream getInputStream(String fileName)
          throws IOException
          InputStream input;
          if (fileName.startsWith("http:"))
               URL url = new URL( fileName );
               URLConnection connection = url.openConnection();
               input = connection.getInputStream();
          else
               input = new FileInputStream( fileName );
          return input;
     public static OutputStream getOutputStream(String fileName)
          throws IOException
          return new FileOutputStream( fileName );
     public static int copy(InputStream in, OutputStream out)
          throws IOException
          int bytesCopied = 0;
          byte[] buffer = new byte[4096];
          int bytes;
          try
               while ( (bytes = in.read( buffer )) != -1 )
                    out.write( buffer, 0, bytes );
                    bytesCopied += bytes;
          finally
               in.close();
               out.close();
          return bytesCopied;
}If that doesn't help then take a look at this thread:
http://forum.java.sun.com/thread.jsp?forum=31&thread=331540

Similar Messages

  • Url.Content on Azure

    I have an ASP.NET MVC 2 application that has page with a link to a pdf file
    <a href="<%= Url.Content("~/Downloads/test1.pdf") %>">test1</a>
    Downloads directory is at MVCApplication1/Downloads
    This works fine locally and on ISS, but returns a page not found when uploaded to Azure.

    Hi,
    Please check the below link as it has the same issue answered.
    http://stackoverflow.com/questions/5076846/url-content-on-azure
    Regards,
    Mekh.

  • Logic Pro x - additional content downloads and installs but it won't show up in my Logic Pro X. Where is the add'l content downloaded and how do I activate on Logic Pro X?

    The additional content downloads and installs, but it won't show up in my Logic Pro X. I cannot find the "Library" folder where this additional content is  downloaded to and can't seem to activate the new loops and instruments in my Logic Pro X (i.e. loops are still greyed out). Any solutions?

    similar problem that I'm hoping revives this thread. Took over 24hrs to dload additional content (after another full day for the actual problem) due to a bad dload rate. so quitted, and relocated closer to my wifi router. Restart, open logic x, Menu bar:  Logic Pro/ Download Additional content ...Tells me i have no internet connection.... Ahh... I do, I'm using it right now! Tried restarting and relaunching. same thing every time.
    Any clues?
    This whole apple upgrade has been so disappointing! All i wanted to do was reinstall logic 9! $2500 later and I'm still struggling. ***!

  • Additional content downloads in Logic not showing up in library

    I am trying to download and install the additional content downloads in Logic which from what I understand includes Jam Packs. I have downloaded and installed everything multiple times but cannot see it appear in the Logic library and cannot use them. Help!
    Message was edited by: trenten7
    I'm not sure how to delete a thread (if you can), but it now works. Logic had to "Index" and restart, and they now appear in library. Good luck to anyone else who searched for answers with this problem!

    Nancy O- thank you for your responses and particularly the information about serverside includes.
    On your second post, you point out correctly that the link to the image is through the Library/images.  That is exactly how the library item appears in the code in my web page.
    Further, the code in the library file appears and is saved as  "images/picture-dot-png" but when it the library item is inserted into html code it appears "Library/images/picture-dot-png".
    Perhaps I am missing an intermediate step?  Are the library items compiled in some way?
    I'm willing to take a look at server side includes, but I'd sure like to get my dreamweaver working right.
    Thanks again.

  • Since V.6, I've been getting this message when I download: Script: chrome://mozapps/content/downloads/downloads.js:1203 I have Mac 1.83GHz Core Duo 2GBram

    Beginning with Version 6 and now with Version 7, I've been getting a hang and this message when I download:
    Script: chrome://mozapps/content/downloads/downloads.js:1203
    Stop Script or continue?
    I have Mac 1.83GHz Core Duo 2GBram

    Hi,
    Please try couple of probable solutions as mentioned below:
    Solution 1:
    1. Close Elements.
    2. Launch the Photoshop Elements Welcome Screen and hold down Cmnd+ alt + shift as you click Editor.
    3. Continue to hold the keys until you see a message box asking if you want to delete Photoshop Elements settings file; click Yes. Elements will open with default preferences.
    Solution 2: In case any network printer is attached try to launch without network or printer uninstall or make different printer as default.
    Now launch PSE and check if it works.

  • There is no application set to open the URL sims3://download/?ofbId=OFB-SIM3:38987

    There is no application set to open the URL sims3://download/?ofbId=OFB-SIM3:38987&encryptedAuthToken=INbCdD6FAe0ND8AcYXJcX FPun4EYsDLeKldH2eNztR1XM90460ejXtN1cD4EpASBNtF4hAJPW6JqlFo0RufA74fgIyqlL5_8Pq-22 vEdrXimqDC5-8U0Uxq1jhl-1b_-w-IkGUio9nplWF_9sUUzTQ...

    I try to download the game from EA sports, which I payed for, but that URL comes up. After that it just wont work so I cant download the game or anything.

  • Retrieving an URL content in ABAP

    Hi Experts,
        I have to read the content of http://.......... URL content to ABAP. Is there any method or function module to read??
    Thanks and regards,
    Venkatraman.N.

    Hi!
    Take a look at the folliwing programms and examples:
    RSHTTP*
    They work really good.
    Best regards,
    Esteban

  • What is the URL for downloading Creative Suite 4 Design Premium to reinstall?

    I had my HD die on my iMac and support gave me a url to download my Creative Suite 4 Design Premium again to make my backup restore system work.  I have decided to switch to a new iMac so I need the url again as the backup again did not let me work even though I deactivated on the old iMac. Anyone know what it is?
    Thanx.

    You should check your Adobe account online to see if there is a download link there for you.
    If not, or alternatively, you can download the trial version of the software thru the page linked below and then use your current serial number to activate it.
    Be sure to follow the steps outlined in the Note: Very Important Instructions section on the download pages at this site and have cookies enabled in your browser or else the download will not work properly.
    http://prodesigntools.com/download-adobe-cs4-and-cs3-free-trials-here.html

  • "Additional Content" downloads can be continued!

    Here's something I wasn't aware of until I just happened to fumble into it:
    The other day, while downloading some of Logic Pro X's "Additional Content" instruments at a place that had free Wi-Fi (I have a limited montly allowance of 5Gb through Verizon), I had to stop about halfway through since it was time to leave. Since there's no way of actually pausing these downloads, I just went offline to force-stop it and figured I'd have to start all over again on a future occasion. ...
    Surprise! The next time I went online (which was at another place with free Wi-Fi) and opened Logic Pro, a "Resume Content Download?" window popped up, giving a choice to either continue, "decide later" or cancel. Of course, I selected to continue and then the download finished from where it had left off! Nice!
    So, apparently, though there appears to be no actual, official (as far as I can tell), obvious way of doing it:
    The Logic Pro X "Additional Content" downloads can be continued later!
    By the way, I've now done this several times, so it appears to not just be a fluke, though it is kind of scary every time I try it.  :-)
    Hopefully, this can be helpful for others who have trouble finding the time or accessability to download some of the larger instruments all at once. Also, hope this works for everyone the way it has worked for me.

    Thanks.Thats big help for sure.Time for a download break now.

  • URL for Downloading Licensed FlashPlayer Does Not Work

    I reapplied for a license to distribute FlashPlayer back in October and was granted a license and a specific URL to download FlashPlayer for distribution on our intranet.  The URL does not work and instead of downloading FlashPlayer the only option is to apply for another license.  I attempted to engage Adobe via Chat and they said I have to post here, but this does not make a lot of sense since the email with the license said the URL for downloading may not be shared with anyone, hence why I am not posting here.
    So have others received a license from Adobe with a non-working URL?  How did you get someone at Adobe to respond?

    Hi Eddie,
    I will forward this to the Licensing folks and will post back when I have a response.
    Maria

  • Re:  Adobe Audition Content Download

    I was instructed to post my question here by the Adobe telephone Customer Support:
    I have recently purchased Audition CS6.
    This provided me with downloadable music and effects through adobe.com, "Adobe Audition Content Download"  (Which referrs to "loopology" in the html address..)
    the site is:
    https://www.adobe.com/cfusion/entitlement/index.cfm?e=auditionloopology
    Adobe Telephone Customer Support has informed me that this audio collection IS royalty-free and attribution-free. 
    What they were not able to answer was this:
    Additionally, does this collection have a Cue Sheet requirement or any other legal restrictions for use in the broadcast arena?
    The EULA link for this collection points to a page that referrs to the entire Adobe product family.  I could not find legal information pertaining to this particular service anywhere on that page.
    Thanks, in advance, for your help!

    rainman_75 wrote:
    Adobe Telephone Customer Support has informed me that this audio collection IS royalty-free and attribution-free. 
    What they were not able to answer was this:
    Additionally, does this collection have a Cue Sheet requirement or any other legal restrictions for use in the broadcast arena?
    I think you'll find that 'attribution free' means exactly that - and we've always regarded it that way. I know the originator of some of it, and he has effectively waived all rights to what he did, so we are presuming that the same thing applies to all of it. This means that effectively, there are no broadcast restrictions, and no cue sheet requirements - although you might want to attribute the collection, just to stop questions, I suppose. I read through the Software Licence agreement, and the part of this that appears to be relevant is this:
    2.3 Content Files. Unless stated otherwise in the “Read-Me” files, Documentation, or other license(s) associated with the Content Files, Customer may use, display, modify, reproduce, and distribute any of the Content Files. However, Customer may not distribute the Content Files on a stand-alone basis (i.e., in circumstances in which the Content Files constitute the primary value of the product being distributed), and Customer may not claim any trademark rights in the Content Files or derivative works thereof. Nothing stated herein shall affect the ownership of the Software as stated in Section 3.
    So, if the read-me's don't say otherwise, you're good to go doing nothing!

  • URL to download Oracle 10g clusterware softare

    Hi,
    Can anyone give me the URL to download Oracle 10g Clusterware software, I found only Oracle 11g Clusterware in download section of Oracle site.
    Thanks

    Below mentioned link will help
    where's RAC 10g download page?

  • Premiere Elements 11 - online-content-download not working

    Download of online-Content (movie-menues etc.) is not working. Are the Servers down?

    premiere-user-v11
    Are you doing one at a time and getting failure or are you hitting the All choice for the Content with the blue ban at its upper right corner?
    Have you checked the following areas to determine if the problem is targeted at one type of Content?
    Graphics Tab for Clip Arts
    Tools Menu or Tools Tab for DVD Templates
    Instant Movies Tab for Movie Themes
    Title & Text Tab for Title Templates
    Just trying to determine the specificity of the problem - All versus selected areas.
    I have found that, at best, the Content download from within the project is a labored and slow process, depending on your Internet connection and Internet speed. Unfortunately there is no alternative since there is no more Content disc when you purchase the box product. But you can save the Online Folder (after download - completed version) to a USB Flash Drive (8 GB capacity) after the first program install so that you can use that for Content for the second install of  Premiere Elements 11 on another computer or in the case where you need to uninstall reinstall Premiere Elements and its Content on one computer. The file size of the completed Online Folder is expected to be about 6 GB.
    We will be watching for your progress.
    Thanks.
    ATR

  • Please share the URL for downloading Weblogic 8.1 with admin server

    Hi,
    Could you please share the URL for downloading the weblogic 8.1 server with admin option for redhat llinux.
    Also could you please me whether we can download the installation guide from some site, I want to do a silent installation of same.
    Regards,
    Balu.

    Hello, you still seem to be pointing people to site(s) that [www.certguard.com] indicates may lead them to lose their certifiaction: viewers please also see also the route you choose ... The Route You Choose
    Edited by: bigdelboy on 01-Jun-2009 08:39 (Please note this refers to a spamming post not to the original post of the thread).

  • The content download cannot be performed because there is not enough available space in cache or the disk is full.

    I deploy all office package via Application deployment. But many system getting failed due to error "The content download
    cannot be performed because there is not enough available space in cache or the disk is full.".
    I delete the cache old file/folder. Now the cache disk space is available. But still this systems showing same error. And it is not retry also. need help for retry application download if failed due to cache disk.

    You should review what your default client cache size is being set to (default 5GB) and then look at the size of the office content you are trying to deliver.
    If the content of the office application exceeds your maximum client cache size setting then the download and subsequent installation will fail.
    Note that normally the download of applications should overwrite old content in the cache unless you have set them to be persistent, the exception to this is the above case.
    To resolve this you will need to increase the client cache size. There are a few ways to achieve this, you can do this either from the Config Manager console via right click tools or via a script that you can run against your clients. Others might like to
    comment on how best to achieve this (if this is indeed your problem).
    Cheers
    Damon

Maybe you are looking for

  • Reg_GRC 10.0 Integration with backend systems

    Hi Everyone, Could you please help me to find out  which all of the below products can be integrated with GRC 10.0 Access control. Click  Schedule PI System BOBJ - CMS BOBJ-DS-CMS SAP Mobile Platform - Derby Afaria ADP ARIS Cloud SOLMON Adobe Live Cy

  • ITunes refuses to copy TV Shows based on episode numbers...!

    I have a lot of TV content in iTunes, some bought from the iTunes store, some I have ripped and encoded myself. Everything is tagged thoroughly and correctly with episode IDs, episode numbers, watched/unwatched flags, series and season info, even epi

  • Ale / Idoc between two different servers

    Hi All, In my scenario i am working on two different servers in which distribution of idoc is carrying out. (Before this i have worked on same server scenarios with different clients.) But present scenario i am working with two diferent servers, like

  • Constant Field Values

    A simple question. Does anyone know how to use Constant Field Values of PAPI? Please paste the sample code. Thanks.

  • Cannot open nikon d90 NEF in lightroom (vista)

    please help!