Downloading files through a MIDlet

Hi there, I am new to the J2ME network connections API, especially for downloading data through a MIDlet. I have a small question I hope you could provide some assistance on.
I was wondering if there was a way to download data (ie: a text file) from a website or server. I know that there is a class called "FileConnection" that may do this, but I was wondering how to use it to do that. Also, is there a way to do it without the FileConnection API for phones that do not support it? And as for when the data is downloaded, where exactly on the phone is it stored? In the RMS? Is there a way to download the data into the "/res" folder directly?
Any help would be appreciated,
thanks,
take care

You can do it by a thread, sample run function is given below
public void run() {
        HttpConnection c = null;
        DataInputStream is = null;
        DataOutputStream os = null;      
        try
            String downloadURL = "yourdownloadurl";
            c = (HttpConnection) Connector.open(downloadURL);   
            c.setRequestMethod(HttpConnection.GET);
            int resCode = c.getResponseCode();   
            is = new DataInputStream(c.openInputStream());
            ByteArrayOutputStream baos = new ByteArrayOutputStream();                       
            os = new DataOutputStream(baos);                     
            int v;
            byte []data = new byte[2048];
            while ((v = is.read(data)) >0 && downloading) 
                os.write(data,0,v);
            os.flush();
            is.close();
            os.close();
            baos.close();
            c.close();
            System.out.println("The file is "+baos.toString());
        catch (Exception e)
}Edited by: Shimul on Oct 7, 2007 3:32 AM

Similar Messages

  • CCMSETUP "failed to download files through BITS"

    Hi
    I'm strugling with my SCCM Clients.
    We use:
    ConfigMgr 2007 SP1. Client version 4.0.6221.1000. Mixed mode, one site. Server installed on Windows 2003 R2, database clustered. Client are Windows XP Pro with SP3. Site has been published in AD.
    Push Client Deployment works fine.
    First I tried to deploy the client with Group Policy. Stopped with "failed to download files through BITS"
    Then I tried to deploy the client with a script, and finally manually. Got the same error message:"failed to download files through BITS".
    End of log file looks like this:
    Starting BITS download for client deployment files
    Failed to download files through BITS
    A Fallback Status Point has not been specified.  Message with STATEID='309' will not be sent
    Kind of stuck here. Please help!

    I solved the "BITS" problem. There was another web-application on the site-server that altered the permissions on the "Default Web Site". The CCM_CLIENT properties had "Script and Executables" selected for "Execute permissions". I Set this back to "None".
    Now trying to deploy the client via GPO another error came: "Installation failed because another program is installing (1618)". This was during the wingapi.msi installation.
    When a new Window XP Pro Computer is installed various applications are installed from GPO and also Office 2007 scripted. I guess this is a challenge for the ConfigManager Client Bootstrap installation.
    So then I tried to deploy the client from startup script, setting the Policy "Maximum wait time for group policy script =0 (infinite)" and the policy "Run startup script asynchronously" = Disabled. This Works!!
    The script will fire each time it boots until it is installed. The GPO installation will not retry to install. Therefore I think a script is a safer way to deploy the client.
    I will test more on this.
    Thanks for pointing me in the right direction!
    -frode

  • Upload and Download file through RFC called by java

    We are trying to download/upload file through rfc function called by java(JCO),In the rfc function,we use WS_DOWNLOAD,but it does not work.
    Any one know about this,Please help ,thanks very much.
    Message was edited by: gw gw

    Hi gw,
    This question looks a little confusing to me.
    WS_DOWNLOAD is used to download files from SAP to the presentation server (your PC).  It will not work through RFC.
    BUT, also if you want to access a function module via RFC is must be RFC enabled (as Anand pointed out).
    AND WS_DOWNLOAD uses a PUSH approach.  It pushes a file to the PC from ABAP.  So even if the two points above weren't a problem it still would not be suitable for what you are doing.
    Perhaps you could explain a little what you are trying to achieve.
    Cheers,
    Brad

  • Download files through web Dynpro

    Hai All,
      Now i am working in web Dynpro2.0.9. "IWDResource" property is used to download and upload files in web Dynpro. "IWDResource" is not supported by web Dynpro2.0.9.what is the alternative way for to download files other than using "IWDResource" property.If you have sample codings send it.
    Thanks in Advance,
    s.v.selva Bala.

    Hallo Anilkumar,
    read my tutorial on Uploading/Downloading Files in Web Dynpro NW04:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d2201c20-0801-0010-49b3-94fca8f590d5">Uploading and Downloading Files (39)</a>
    You are right, that the new on-demand-stream concept based on the IWDResource-API (Resource Simple Type) is not applicable in NW04.
    Regards, Bertram

  • Uploading and downloading files in webdynpro java

    how to upload and download xl files in webdynpro java application .

    Hi ,
    Refer these links they maybe helpful to you
    You can check this sampple example from SDN
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40db4a53-41a9-2910-d4a2-9c28283f6658
    Uploading and Downloading Files In Web Dynpro Java
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f
    http://help.sap.com/saphelp_nw04/helpdata/en/43/85b27dc9af2679e10000000a1553f7/content.htm
    Uploading and Downloading Files In Web Dynpro Tables
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f
    Some more links regarding Uploading and DownLoading Files
    Uploading and downloading files
    Upload and Download file through RFC called by java
    Regards,
    Saleem

  • Uploding file through FTP

    Hi
    How can i upload file and download file through FTP server .is any body has some sample code.pls help me
    Thanks!!

    I think there one undocumented sun.net.ftp
    U can try with that pkg...Better yet, don't.
    Why Developers Should Not Write Programs That Call 'sun' Packages
    http://java.sun.com/products/jdk/faq/faq-sun-packages.htmlI recommend the Jakarta Commons Net package...
    http://jakarta.apache.org/commons/net/

  • Unable to download files with IE 9, 10 or 11

    We have a user who is not able to download files using IE. She's running Windows 7 Pro 32-bit. She's able to download using other browsers. This seems to have started when I changed her local rights from Local Admin to Standard user.
    I've disabled all plugins, downgraded from IE10 to IE9, upgraded to IE11. We've also tried running her system in Safe Mode with networking still no luck. I also changed her local rights from standard back to Admin.
    I've tried most of what was suggested here: https://social.technet.microsoft.com/Forums/ie/en-US/7a8e5897-9708-4506-9efc-8f888efbba21/ie9-and-ie10-cannot-downloadopen-any-files
    Any other suggestions?

    Hi,
    Is there any error message when this system couldn't download file through IE? Is this computer added to Domain?
    It would be better to provide a screenshot for this problem.
    Roger Lu
    TechNet Community Support

  • Hi im having huge problems trying to install flash for my mac 10.5 imac, iv gone through the internet and tried all of the solutions, everytime i try to install flash it says cant read the download file, or it just wont install, anybody plz help!

    hi im having huge problems trying to install flash for my mac 10.5 imac, iv gone through the internet and tried all of the solutions, everytime i try to install flash it says cant read the download file, or it just wont install, anybody plz help!
    iv unistalled flash, iv checked plug ins it just wont work,

    It would have been a great help to know precisely what Mac you have, so some of the following may not apply:
    You can check here:  http://www.adobe.com/products/flash/about/  to see which version you should install for your Mac and OS. Note that version 10,1,102,64 is the last version available to PPC Mac users*. The latest version,10.3.183.23 or later, is for Intel Macs only running Tiger or Leopard, as Adobe no longer support the PPC platform. Version 11.4.402.265 or later is for Snow Leopard onwards.
    (If you are running Mavericks: After years of fighting malware and exploits facilitated through Adobe's Flash Player, the company is taking advantage of Apple's new App Sandbox feature to restrict malicious code from running outside of Safari in OS X Mavericks.)
    * Unhelpfully, if you want the last version for PPC (G4 or G5) Macs, you need to go here:  http://kb2.adobe.com/cps/142/tn_14266.html  and scroll down to 'Archived Versions/Older Archives'. Flash Player 10.1.102.64 is the one you download. More information here:  http://kb2.adobe.com/cps/838/cpsid_83808.html
    You should first uninstall any previous version of Flash Player, using the uninstaller from here (make sure you use the correct one!):
    http://kb2.adobe.com/cps/909/cpsid_90906.html
    and also that you follow the instructions closely, such as closing ALL applications (including Safari) first before installing. You must also carry out a permission repair after installing anything from Adobe.
    After installing, reboot your Mac and relaunch Safari, then in Safari Preferences/Security enable ‘Allow Plugins’. If you are running 10.6.8 or later:
    When you have installed the latest version of Flash, relaunch Safari and test.
    If you're getting a "blocked plug-in" error, then in System Preferences… ▹ Flash Player ▹ Advanced
    click Check Now. Quit and relaunch your browser.
    You can also try these illustrated instructions from C F McBlob to perform a full "clean install", which will resolve the "Blocked Plug-in" message when trying to update via the GUI updater from Adobe.
    Use the FULL installer for 12.0.0.44:  Flash Player 12 (Mac OS X)
    And the instructons are here: Snow Leopard Clean Install.pdf
    (If you are running a PPC Mac with Flash Player 10.1.102.64 and are having problems with watching videos on FaceBook or other sites, try the following solution which fools the site into thinking that you are running the version 11.5.502.55:)
    Download this http://scriptogr.am/nordkril/post/adobe-flash-11.5-for-powerpc to your desktop, unzip it, and replace the current Flash Player plug-in which is in your main/Library/Internet Plug-Ins folder, (not the user Library). Save the old one just in case this one doesn't work.

  • I used to be able to download files from the Harddrive of my Sony Handycam, but now it won't let me import them while going through "log and transfer."  I have tried to update my settings, but this doesn't seem to work.  Any help would be much appreciated

    I used to be able to download files from the Harddrive of my Sony Handycam, but now it won't let me import them while going through "log and transfer."  I have tried to update my settings, but this doesn't seem to work.  Any help would be much appreciated

    Hard Drive:  The Hard Drive is on my camera (Sony Handycam)
    Just needed some info on what is going on with your particular system.
    Knowing the exact camera model will also assist us.
    If this camera is standard AVCHD you should be able to connect with USB to Mac with FCE open and use Log and Transfer without all the fiddling around converting etc.
    What FCE does during ingest is convert files to AIC. (Apple Intermediate Codec)
    FCE cannot read the individual files in the BDMV folder, that's why all the converting is required when you use that method.
    BTW: regards formatting drives/cards/memory on cameras; it is wise to use the actual device to format rather than a computer. This is a prime cause of read/write goof ups with solid state media. This applies to still or video cameras.
    Keeping the COMPLETE card/memory structure in tact is vital for successful transfers.
    Try here for some trouble shooting tips:
    https://discussions.apple.com/message/12682263#12682263
    Al

  • How to download files in jsp code {through save dialog}

    can you help me to download files in jsp code {through save dialog}
    i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded
    response.setHeader("Pragma", "public");
    response.setHeader("Cache-Control", "no-cache");
    *** download file
    if((trans !=null)&&(trans.equals("download")) )
    response.setContentType ("application/x-download");
    response.setHeader ("Content-Disposition","attachment;filename=\""+fileName+"\"");
    %>
    <script>
    window.location.href=<%=gallerypath+fileName%>';
    </script>
    <%
    trans="";
    //System.out.print("download : "+fileName );
    //***************************************

    Can you try below code, It should work...
    <%
    String myFileName = request.getParameter("fileName");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + myFileName + "\"");
    String root = "D:/";
    InputStream in = null;
    ServletOutputStream outs = response.getOutputStream();
    try {
    in = new BufferedInputStream
    (new FileInputStream(root + myFileName));
    int ch;
    while ((ch = in.read()) != -1) {
    outs.print((char) ch);
    finally {
    if (in != null) in.close(); // very important
    outs.flush();
    outs.close();
    in.close();
    %>

  • I have a Nikon d610 and am using PS CS6. I am unable to download my raw files through Bridge on my mac. I have downloaded the most recent Camera Raw files - 8.7.1 - what should I do next.

    I have a Nikon d610 and am using PS CS6. I am unable to download my raw files through Bridge on my mac. I have downloaded the most recent Camera Raw files - 8.7.1 - what should I do next.

    The D610 needs ACR 8.3 so you are easily covered there.  I am not entirely clear on the process you are using the bring the files onto your hard drive.  The safest way is to simply bring all the NEF files into a folder on your hard drive, then find them with bridge and open from there.
    If still stuck, open Photoshop, and go Help > About plugins > Camera RAW and check that 8.7 installed OK.

  • I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    Exactly what do you mean by a 'downloader'?
    Thanks
    Pete

  • Check if file downloaded successfully , through Open Save dialog box

    hi,
    In the jsp I have a download link through which user can download a file which is located on the server . I have achieved this by setting the response type in servlet as follows => response.setHeader("Content-Disposition", "attachment; filename=" + fileName); .When the jsp page loads the user is shown a Open Save dialog box for downloading the file. The user can download the file or cancel the operation.
    But now I need to track if the user has downloaded the file successfully on his m/c , depending on which a flag will be updated in the database . I am not able to track this event . Pls help how I can check if the file has been downloaded successfully and do further processing.

    This is fully dependent on the client side. You can never rely on that.
    In most cases you could check if any byte of the file is written to the outputstream and/or no IOException is been thrown, but some webbrowsers (such as Firefox) will download the file immediately while the client still need to choose 'save' or 'cancel'. Only when the client chooses 'cancel' the download will be aborted and the file will be deleted. But if the file is small and/or the network is fast, then the file download might be already completed at that time.
    Again, you can never rely on what happens at the client side.

  • Downloading the file through http.

    Had anyone tried to download the zip file through http. If anyone had, please help to approach this.Thanks in advance.
    Also the way to unzip the downloaded file.

    Thank u for reply.I am trying to download the content of the xml file and download using NSUrl and parse it using NSXmlParser.I would like to know is there any way to handle the huge amount to be downloaded.

  • Not able to download a big xml file through Http

    Hi
    I am trying to download a large file around 8 MB, but I am  not able to download this file through Http or WebClient. can anyone please let me know how can I download the large file in Windows Phone 8 through Http or WebClient.
    When I trying to download the file then System got hang for some time and after that connection break type of popup shown the  nothing happened.
    sandeep chauhan

    Hi Sandeep,
    I used
    this code snippet to download
    the sample file (9.9M) in windows phone 8, it seems work fine. Since you’ve not posted anything about your code, I suggest you test the above code to see if the problem is caused by your code snippet.
    Windows phone silverlight 8.1 provides an effective way to download large file.
    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.networking.backgroundtransfer.backgrounddownloader.aspx. Please consider if you can upgrade to silverlight 8.1
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

Maybe you are looking for