How to download a file from a website and save it locally

Hi people,
I have a number of URLs at hand that point to certain class files, e.g.
http://www.mywebsite.com/classes/MyClass.class
What i would like to do is to download MyClass.class into a temporary folder on the local disk. Does anyone know how to do this? I've read about HttpURLConnection etc., but its all very confusing!
Cheers,
JG

you need to create a URL to the url
URL url = new URL("http://www.mywebsite.com/classes/MyClass.class");
HttpURLConnection c = (HttpURLConnection)url.openConnection();
then you need to acquire an input stream from the connection. Roughly this is
InputStreamReader r = (InputStreamReader)c.getInputStream();
FileWriter w = new FileWriter("c:\\temp\\" + name);
int b;
while((b = r.read()) != -1) {
w.write(b);
close all streams
something like this - will let you work out the rest..dont forget to try/catch all the IO exceptions.

Similar Messages

  • How to download a file from the net and save it into .txt format in a datab

    Can some one show me a tutorial on how to download a file from the net and save it into .txt format in a database?
    Thank you,

    http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html

  • When downloading a file from google drive and save in my phones document directory,the file size is compressed. Why?

    I have downloaded files from "Dropbox" and save in phones document directory,After downloading in document directory,the size of the download file is same as the actual size in dropbox. I can also open it from document directory.Everything is ok. But when I follow the same process for google drive files, the file size is compressed(if actual size of file is 1.2Mb the download file size is 61Kb). So I can not open it from document directory.So, How can i download the actual size of the file in document directory? I am using google api objectivec client for google drive.
    Thanks in advance.

    If an iphone were to try to download a full size document ot photo, it woul overload its own ram, and crash, resulting in a laggy iphone. Therefore it is compresses

  • Is there how to download music directally from the ipod and save them into the ipod's library?

    I don't want apps like music download pro, download lite...

    For non-iTunes purchased music you need a third-party program like one of those discussed here:
    Copy music from Ipod to new computer...: Apple Support Communities
    For iTunes purchases:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer

  • How to download a file from Oracle UCM using OSB

    Hi,
    How can I download a file from Oracle UCM and save it on a filesystem using OSB 11.1.1.5.
    Thanks

    UCM supplies webservice interfaces which let you retrieve the filecontent by soap calls from UCM (http://ucmhost/_dav/cs/idcplg for example). (maybe you should enable some settings on ucm to have this webservice interface getting published).
    This services for example has 2 operations getFileByID and getFileByName.
    So you can just call these services from within OSB.
    After that you need to do some tests if you eitherway need to create a file-transport business-service and call this one from your proxy service or create a messageType proxyservice (binary)  which calls this file-transport business service to be able to write fo filesystem.
    I think for the OSB book i used a jca file adapter generated in Jdeveloper and used that one to write to filesystem.

  • How to pick a file from a website

    Hi All,
    I have a requirement like this. I need to pick a file from a website for which i have the link and the file name . Its a .csv file. can i use file adapter to pick that file? can i mention the http link in the source directory field?  or suggest me some way to pick that file . Its a website not a web service.
    reagrds
    jhansi

    HI Hema,
    A work around i see is to use run operating system command before message processing option in sender file adapter.
    Here I'd write a  .bat file which which will execute a java class..
    Basically I'll write a java class to download the file from the URL and keep it. And this file will be picked up by XI.
    May be the same thing can also be achieved using scripts but i have no idea on dat...
    Any how, my java code segment wud be something like
              try {
                      String webFile =
                         "http://www.dilbert.com/comics/dilbert/archive/images/dilbert2002222271107.gif";
                      URL url = new URL(webFile);
                      InputStream is = url.openStream();
                      FileOutputStream fos=new FileOutputStream("C://MyFolder//dilbert2002222271107.gif");
                      int oneChar;
                        while ((oneChar=is.read()) != -1)
                           fos.write(oneChar);                     
                        is.close();
                        fos.close();               
              } catch (Exception e) {
                   // TODO: handle exception
                   e.printStackTrace();

  • How to download a file from server machine to client machine using jsp

    Hi,
    In my application, I have an excel file stored on my server machine. How can I download that excel file on to my client machine using jsp. Is there any other way I can open that file from my machine and save it in my machine using jsp/java?
    Its an emergency for me to do this.
    Can anyone provide me the full code to download a file from server machine as I don't have
    time to browse through various sites.
    thanks in advance,
    Tiijnar

    Please post your code using code tags (click on CODE above the text area, when posting)
    response.setContentType("application/octet-stream");Why octet-stream? Set the correct mime-type.
    String disHeader = "Attachment; Filename=\"filename\"";The filename should just be the file's name. Not the complete path to the file! This will tell anyone where the file is located on the server. It's also inconvenient because by default,the browser will suggest it as the name for the download.
    Your way of writing to the output stream is just plain wrong. See this snippet (picked from [http://balusc.blogspot.com/2007/07/fileservlet.html])
            BufferedInputStream input = null;
            BufferedOutputStream output = null;
            try {
                // Open streams.
                input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
                output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
                // Write file contents to response.
                byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
                int length;
                while ((length = input.read(buffer)) > 0) {
                    output.write(buffer, 0, length);
                // Finalize task.
                output.flush();
            } finally {
                // Gently close streams.
                close(output);
                close(input);
            }

  • How to download a file from Path specifed

    Hi Frndz..
    How to download a file from a specified path like  , i have a file on server in the path like "C://temp/Sap.pdf"
    I want to download this to user desktop..
    Thanks in Advance
    regards
    Rajesh

    Hi,
    For file down load u have to use a UI element as "File download".
    u just create context attribute as setdownload_res and file data.
    setdownload_res as of type "com.sap.ide.webdynpro.uielementdefinitions.Resource" then bound it to the ui element "resource".
    file data as of type "com.sap.tc.webdynpro.progmodel.api.IWDInputStream"
    and set calcuclated as true and read only as true.
    then in doinit method u just write this code
    IWDAttributePointer attr = wdContext.currentContextElement().getAttributePointer("fileData");
    IWDResource res = WDResourceFactory.createResource(attr,null,WDWebResourceType.UNKNOWN);
    wdContext.currentContextElement().setDownload_res(res);
    wdComponentAPI.getMessageManager().reportSuccess(""+c);
    after this in the getter method u write this code
    IWDInputStream stream = null;
    try
    stream = WDResourceFactory.createInputStream(new FileInputStream(new File("<pathof the file to be download>")));
    catch(Exception e)
    e.printStackTrace();
    return stream;
    also look at this thread  How to DownLoad any type of File from the server(PDF,XLS,Word)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f
    PradeeP

  • How to download a file from the internet using terminal

    how to download a file from the internet using terminal
    does any one know how to download afile from the internet using the Terminal application?

    Use curl. Something like this:
    curl -O http://www.example.com/filename.zip
    For more info, type +man curl+.

  • How to download a file from AL11 inot Excel format without collapse the col

    Hi,
    Please suggest how to download a file from AL11 to Excel sheet.currenlty all field are merging into single column.I writing this file via using DATASET.
    Regards
    Ricky

    Hi,
       Try this code,
    ==============================================
    TYPES : BEGIN OF ty_emp,
              empno(2) TYPE c,
              empid(10) TYPE c,
              empname(3) TYPE c,
            END OF ty_emp.
    DATA : it_emp TYPE TABLE OF ty_emp,
            wa_emp TYPE ty_emp.
    DATA : pbk TYPE string.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS : p_file TYPE rlgrap-filename.
    PARAMETERS : p_asfile TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK b1.
    pbk = p_file.
    OPEN DATASET p_asfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      DO.
        READ DATASET p_asfile INTO wa_emp.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND wa_emp TO it_emp.
      ENDDO.
    CLOSE DATASET p_asfile.
    Filling the already created file with download PS radiobutton
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                  =
          filename                      = pbk
      FILETYPE                      = 'ASC'
         append                        = 'X'
         write_field_separator         = ' '
      HEADER                        = '00'
      TRUNC_TRAILING_BLANKS         = ' '
      WRITE_LF                      = 'X'
      COL_SELECT                    = ' '
      COL_SELECT_MASK               = ' '
      DAT_MODE                      = ' '
    IMPORTING
      FILELENGTH                    =
        TABLES
          data_tab                      = it_emp
    EXCEPTIONS
      FILE_WRITE_ERROR              = 1
      NO_BATCH                      = 2
      GUI_REFUSE_FILETRANSFER       = 3
      INVALID_TYPE                  = 4
      NO_AUTHORITY                  = 5
      UNKNOWN_ERROR                 = 6
      HEADER_NOT_ALLOWED            = 7
      SEPARATOR_NOT_ALLOWED         = 8
      FILESIZE_NOT_ALLOWED          = 9
      HEADER_TOO_LONG               = 10
      DP_ERROR_CREATE               = 11
      DP_ERROR_SEND                 = 12
      DP_ERROR_WRITE                = 13
      UNKNOWN_DP_ERROR              = 14
      ACCESS_DENIED                 = 15
      DP_OUT_OF_MEMORY              = 16
      DISK_FULL                     = 17
      DP_TIMEOUT                    = 18
      FILE_NOT_FOUND                = 19
      DATAPROVIDER_EXCEPTION        = 20
      CONTROL_FLUSH_ERROR           = 21
      OTHERS                        = 22
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ==============================================
    Regards,
    Krrishna

  • Hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.

    hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
    i do not have a mac home pc. just a regular pc

    I had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do:  Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version!    One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck

  • HT6154 how to download the files from mail like gmail or yahoo or hotmail to my iphone 5s.I have not seen the option in my iphone 5s

    how to download the files from mail like gmail or yahoo or hotmail to my iphone 5s.I have not seen the option in my iphone 5s

    Download what files?
    What is the actual problem that is occurring?

  • Corrupted content error when trying to download .pdf file from one website.

    Unable to download .pdf file from a website, but IE8 provided the download without hesitation.
    Both v7 and v8 produced the same message:
    "Corrupted content error"
    The page you are trying to view cannot be shown because an error in the data transmission was detected.
    This may be a particular website problem, or it may be common to the particular industry segment and their protocols.
    I have followed the help leads and examined the profile for Firefox as used in this instance. Nothing untoward seemed to pop out as a causal factor.

    Reworked some of the javascript for our webserver and fixed the problem.

  • I'm having to re-install PSE 11 on a new hard Drive.  I clicked the installer and it ran, but says it's missing the .exe file.  I then downloaded PSE 11 from your website and when I unzipped it and ran it, it wanted to uninstall PSE 11.  Now I'm contactin

    I'm having to re-install PSE 11 on a new hard Drive.  I clicked the installer and it ran, but says it's missing the .exe file.  I then downloaded PSE 11 from your website and when I unzipped it and ran it, it wanted to uninstall PSE 11.  Now I'm contacting you

    Okay, so, fast forward from July to now -
    - I've visited my closest Apple store's genius bar twice now. (Over an hour and a half away.)
    - My computer spent at least 8 hours behind their closed doors in the workshop
    - Several complete erases of the harddrive have taken place
    - Most of the Apple geniuses I dealt with were nice and very knowledgeable, but they were and still aren't 100% sure exactly what is wrong with my computer.
    The good news is:
    - They were able to at least get it running again, with a clean install from their servers of OS X Lion 10.7.5
    - They believe that my problems stem from either 1 of 2 things:
            - Faulty Hard Drive (even though it is brand new)
             - The wrong build of software being installed.
    Now, while the wrong build does seem like it could be the problem, it doesn't make sense in the aspect that all of the initial problems began when the first hard drive failed. The same problems continued when I changed out the failed hard drive with the brand spanking new one, and only slightly improved when I was able to successfully install the OS that came with the original disks for my computer. I'm not convinced this thing is back to normal, but hopefully I can make it last through getting a shiny new retina Macbook Pro in the coming future. Thank you so much to everyone who read and replied to this post!
    - Andrew =)

  • How to download a form from a website off of internet

    how to download a form from a website off the internet

    Hi,
    Let’s verify the following:
    Whether you want to download a form from a SharePoint site.
    Whether you want to download a form from a SharePoint online or on premise.
    You can Download a copy from SharePoint site.
    Also you can Go to the library->Library->Open with Explorer->copy the form that you want to download.
    Besides, take a look at the article about sync with OneDrive for Business or Workspace:
    https://support.office.com/en-us/article/Sync-with-OneDrive-for-Business-or-SharePoint-Workspace-73e03390-fadb-40d5-b713-e9db2e0950d5
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

Maybe you are looking for

  • Follow up to "freezes"

    TO: bbb_999 Thank you for the response. To claify my problem, I can open a project in CS5 OK. The sequence and clips come up, and I can manipulate the, eg, resize a still image, change in/out points on a clip, etc When  I click on ">" to play the pro

  • Mouse will wake not wake up mac mini

    Just purchased and hooked up a Gyration cordless optical air mouse and keyboard to my mac mini. The mini is connected to my television. When I put the mini to sleep I can not wake it back up with these devices. The light on the RF receiver hooked in

  • App Store and Mail crash after update to Mountain Lion

    I installed Mountain Lion on an empty partition on my HD and then used Migration Assistant to bring over my user account. I can boot into ML but the App Store and Mail crash when launched. Has anyone else seen this, or better yet, have a solution? Th

  • My iphone is full of photos - how do I copy to get available space?

    My iphone is full of photos - how do I copy to get available space?

  • Date difference based on the conditions is giving wrong values

    Hi, In creating the formula for conditional date difference calculation, i.e., if (sto date is 0) then (act date - mat rel date) else (sto date is not equal to 0) then (sto date - mat rel date) So I tried with, (sto date == 0) * (act date - mat rel d