Copy a file from URL to local HDD

Hi,
I've got 2 problems:
1. I'm an absolute beginner and an german-speaking user of this forum
2. I want to copy a file from within a signed applet (with full access permissions) from a URL on the server to a local directory on the client. It works with .txt or .ini files, but not with .dll or .exe. The .exe file has only 1KB instead of the 5MB and contains only something like "-1". Help!!
Here's what i made:
URL updateurl = new URL(getCodeBase() + "testfile.exe");
InputStream in = updateurl.openStream();
FileOutputStream out = new FileOutputStream("C:\\temp\\testfile.exe");
byte[] buf = new byte[4096];
int len;
while ((len = in.read(buf)) > 0)
     out.write(buf, 0, len);
out.close();
in.close();
Thanks for any help!
cmon42

From looking at the code I can't see any blatant errors.
The only thing I can think of, is: is your code wrapped by a try/catch block which you are ignoring?
The reason I ask, is that maybe you are not downloading the file you intended in the first place. The reason I think this is because of the line:
URL updateurl = new URL(getCodeBase() + "testfile.exe");Shoudn't there be a separator between getCodeBase() and testfile.exe? Only a guess, since getCodeBase may already return the separator.
HTH,
Manuel Amago.

Similar Messages

  • Need to copy .txt file from FTP server and downloaded on local server directory.

    I need to figure out a way to copy .txt file from ftp server in local server directory using sql jobs.

    Below links will help achieving it:
    https://www.virtualobjectives.com.au/sqlserver/ftp_scripts.htm
    http://www.mssqltips.com/sqlservertip/2884/sql-server-integration-services-ssis-ftp-task-for-data-exchange/

  • I am new with iMac and I am trying to copy some file from my external HDD but it does not let me also I can't delete anything from this HDD using the finder. Can somebody help me , please?

    I am new with iMac and I am trying to copy some file from my external HDD that a used with my PC but it does not let me also I can't delete anything from this HDD using the finder. Can somebody help me , please?

    No, unfortunately, when you format a drive, it will erase all the contents. So you will need to find a temporary "storage" place to put the stuff using a PC so you have access to it. Then reformat using Disk Utility (Applications > Utilities). If only using with mac, format Mac OS Extended (Journaled) and use GUID Partition scheme under Partitions/Options. After formatting, you can drag the files back.

  • How to copy a file from application server to local system

    Guys,
    Need to copy a file from application server to local system.Is there an FM for the same.
    Tried searching for it but couldn't find anything useful.
    Code snippets will be highly appreciated.
    Warm Regards,
    P.
    Moderator message: very frequently asked and answered question, obviously you did not search thoroughly, all points removed.
    Edited by: Thomas Zloch on Dec 3, 2010 4:48 PM

    hi,
    You can use the transactions CG3Y or through program u can do like this..
    DATA: BEGIN OF IT_FILE OCCURS 0,
                    LINE TYPE STRING,
               END OF IT_FILE.
    OPEN DATASET <file_name>  FOR INPUT IN TEXT MODE ENCODING DEFAULT.
            IF SY-SUBRC IS INITIAL.
              DO.
                READ DATASET<file_name> INTO IT_FILE-LINE.
                IF SY-SUBRC = 0.
                  APPEND IT_FILE.
                  CLEAR IT_FILE.
                ELSE.
                  EXIT.
                ENDIF.
              ENDDO.
            ENDIF.
    CLOSE DATASET <file_name>.
    Download it to local system using  FM - GUI_DOWNLOAD

  • How to copy the backup files from TAPE to Local disc

    Hi Gurs,
    i want to make as replica trrough  PRD offline backup , on new server, while database installing i will take the option systemcopy /backup/restore , so for that how installation master can recognise the tape from tape device, so that now i wanted to copy the backup files from Tape to local disk so that it was already mounted ,i can show the path of backup files.
    the OS is Susi 9
    Oracle 9i
    ECC 5.0
    please any one can help me
    cheers

    What do you use to backup the files to disk? cpio? dd?
    Markus

  • How to play .wav file from URL in web browser embed

    Hi;
    I want to play a .wav sound file in embed default media player in IE. Sound file is on some HTTP location. I am unable to sound it in that player.
    Following is the code.
    URL url = new URL("http://www.concidel.com/upload/myfile.wav");
            URLConnection urlc = url.openConnection();
            InputStream is = (InputStream)urlc.getInputStream();
             fileBytes = new byte[is.available()];
             while (is.read(fileBytes,0,fileBytes.length)!=-1){}
    BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
             out.write(fileBytes);Here is embed code of HTML.
    <embed src="CallStatesTreeAction.do?ivrCallId=${requestScope.vo.callId}&agentId=${requestScope.vo.agentId}" type="application/x-mplayer2" autostart="0" playcount="1" style="width: 40%; height: 45" />1. If I write in FileOutputStream then it plays well
    2. If I replace my code of getting file from URL to my local hard disk. then it also works fine.
    I don't know why I am unable to play file from HTTP. And why it plays well from local hard disk.
    Please help.

    You'll have to ask the devleopers of sencha and phonegap.

  • Failed to read wsdl file from url

    Hi all,
    I am struggling with WL 9.2, consuming a WSRP enabled portlet at the following point:
    Having created a proxy portlet, refering to the WSDL of the WSRP producer, I did successfully deploy the portal. When accessing the portal and consuming the portlet the following exception is thrown:
    com.bea.wsrp.faults.TransportException: Failed to read wsdl file from url due to -- java.net.ConnectException: Tried all: '8' addresses, but could not connect over HTTP to server: 'www.w3.org', port: '80';
    The WSDL includes a schema (http://www.w3.org/2001/XMLSchema). The URL is definetely accessible by the server.
    I am open for any kind of support ;) Thanks in advance!
    Kind regards,
    Matthias

    Yes, they are all local schemas. The way ALSB works, even if the import path in the wsdl or parent schema doesn't exist, relative to the current directory, you can specify which schema resolves that reference. My WSDL imports several schemas, all of which import others. When I was done importing all the schemas and resolving references, all the references in WSDLs and XSDs were assigned and valid. However, after all of those imports and reference resolution, it still says the WSDL is invalid, with the following odd error message:
    The WSDL is not semantically valid: Failed to read wsdl file from url due to -- java.net.MalformedURLException: no protocol: /XMLSchema/PaymentServices/Resources/PaymentServices-200802.
    That path listed refers to one of the schemas imported by the WSDL. The reference to that schema in the WSDL was resolved, and it doesn't complain about that reference.

  • Copy a file from server to the client - URLConnection to a Portal page

    Hello:
    I have an application running on the client side. When the app startup it must open a file which is at the server side, to be more specific, the file is at KM content of the portal.
    I try to read it with URLConnection to copy the file from the server to the client, the app will do it, but "Server returned HTTP response code: 401 for URL:"
    If you copy&paste the url's file directly on the browser (http://host:port/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/ImagenesIM/file.txt) a login popup (look and feel windows) is display. After entering the user and psw the file is open without problem.
    Any idea what can I use or how do it ?.
    I think that probably I have to move the app to a was directory instead of portal directory.
    The app is execute via *.jnlp with a link at a portal page.
    Thanks a lot for your time.

    Javier,
    401 means authentication error, i.e. your application is not authenticated to KM.
    What you can do? Actually, it depends. Check current cookies in your application, probably there are SSO coockie or J2EE authentication cookie. You may try to set this cookies in URLConnection (via addHeader). Otherwise you have to supply authentication creadentials to URLConnection (also via addHeader, most probably, via Basic HTTP authentication scheme).
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • Can't copy some files from Windows 7 to Mac OSX over network

    Hi,
    I'm running the latest version of Max OSX v10.8.4 on a brand new Macbook Pro.
    I have followed the setup instructions at http://www.7tutorials.com/how-change-workgroup-mac-os-x-easy-networking to access my Macbook from Windows, and http://www.howtogeek.com/howto/24950/how-to-share-a-folder-in-os-x-with-windows/ to share some folders from my Macbook to Windows.
    I am now trying to copy some files from my Windows 7 Pro (SP1) computer to my Mac, and have hit the following problems:
    I can view my Macbook in my list of local networked computers on WIndows, but I cannot access it. Clicking on it causes Windows 7 to try and access it, but then I get a message after a minute saying the network path could not be found. However, if I manually enter the IP address of my Macbook in the Windows address bar (\\192.168.0.191), I can view and access all the shared folders. I can never access the Macbook via it's computer name (\\MACBOOK-ROB).
    I cannot copy some files from Windows to my Macbook shared folders via Windows. There is nothing to distinguish these files from the hundereds of other files that I have successfully copied to my Macbook. They are pictures and music with no special characters in the filenames, not overly long filenames or folder paths, no access restrictions, or any other security restriction that I can see. However, every single attempt to copy these files to my Macbook results in WIndows reporting that access to the destination was denied.
    I have tried both these above scenarios on WiFi and Ethernet, and the results are the same.
    So:
    Why am I unable to access my Macbook by it's computer name on the network? How can Windows see it, but not access it?
    What are the limitations on transferring files over SMB that is (presumably) causing these specific files to fail?
    Thanks for any help you can offer.

    I have a fix for inability to copy files. I had the same problem moving a lot of old files across my LAN from a Windows XP machine to a Mac Mini running Mountain Lion. After confirming copy of some special file, I would get an error that terminated the copy operation, and info on the Mac side would show a locked folder.
    I finally decided to eliminate all special files on the Windows side, before copying, by running
         attrib -s -h -r /s /d [drive or folder]\*.*
    in a command window. Running attrib /?  tells what the arguments mean, but it doesn't explain that you need the *.* to make the command go through the hierarchy clearing the special attributes on all the files.
    After I did that, and then used drag and drop between two Windows Explorer windows (one on the Windows drive, on on the target drive on the Mac), the whole move operation ran to completion without stopping either for error or to ask for confirmation.
    I do not have a fix for the inability to access some computers by name rather than by IP address. I'm looking into the possibility of activating bind on the Mac but I haven't done anything yet.

  • How to copy a file from one PC to another in ABAP program

    Hello Friends,
    I have a requirement where I have to copy a file from a central location ( central servers like
    inblr102 or
    dwdf ) and save it on local PC in ABAP code. Also, while saving it should ask for the path on PC. Can any of you please help me in this?
    Thanks in advance!
    Divya

    Hi,
    Check out this link. This deletes file,  probally you will get some hint to copy.:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/deleting%252bfile%252bfrom%252bwindows
    Thanks,
    Krishna

  • Can't copy all files from a CD-R

    I have a number of CD-Rs of family photos.  I made the disks on a Dell PC with a horizontally mounted CD-RW Drive in 2005.  I recently tried to load them onto my iMAC, but I could only copy about half of the files before the drive hung-up.  The drive would often make noise and then slow to a near inaudible crawl and then say the file(s) could not be copied.
    I was able to copy the missing files to a memory stick at a local library on an HP PC with a horizontally mounted drive, so the disks are OK.  Interestingly, I had trouble with the disks at a library with iMAC-like HP PCs, i.e., all-in-one monitor/pc/optical-drive with a vertically mounted drive.
    Other drive-related problems: (1) friends have trouble playing Audio CD-Rs I've made for them, (2) I can't copy a DVD-R with MackTheRipper (PowerPC), the DVD-R plays fine.
    Is this a drive issue, a drive orientation issue, or something else?
    Thanks for your help.

    Hi all.  I am trying to copy all files from a flash: on a CME to a
    usbflash drive.  I am able to do so, but only one at a time.  Is there
    a away to copy all files at one time so I dont have to name them
    individually when copying all of them over?  Thanks.
    Check out the below link hope to help !!
    https://cisco.com/en/US/products/hw/routers/ps233/products_tech_note09186a00800a6744.shtml
    Ganesh.H

  • How can I copy mp3 files from my Itunes library to an SD card for use in a non-apple phone?

    How can I copy mp3 files from my Itunes library to an SD card for use in a non-apple phone?  I can physically copy the tunes as mp3's but the phone does not seem to be able to play all of them.   Do I need to copy an entire album or can I just pick & choose individual songs?   The phone is question is an LG running who knows what for an operating system.

    AAC is Advanced Audio Coding.  Basically it's a format that sounds better than MP3 but doesn't take up as much space as a lossless format (like you'd have on a CD).  More than likely you've had that encoding turned on when you ripped your music into itunes (it's the default encoder).  Therefore your LG phone won't play them.
    You need to turn off the AAC format by going to the iTunes menu, Preferences, General (at the top), then clicking the "Import Preferences" button.  Change the AAC Encoder to MP3 Encoder.  After that you'll have to make MP3 copies of your songs by right clicking them and selecting "Create MP3 Version."  You'll get a copy of the song that should transfer to your SD card and have MP3 encoding.  Hopefully your phone will play that.

  • How to display a dynamic image file from url?

    Hey,I want to display a dynamic image file from url in applet.For example,a jpg file which from one video camera server,store one frame pictur for ever.My java file looks like here:
    //PlayJpg.java:
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class PlayJpg extends Applet implements Runnable {
    public static void main(String args[]) {
    Frame F=new Frame("My Applet/Application Window");
    F.setSize(480, 240);
    PlayJpg A = new PlayJpg();
    F.add(A);
    A.start(); // Web browser calls start() automatically
    // A.init(); - we skip calling it this time
    // because it contains only Applet specific tasks.
    F.setVisible(true);
    Thread count = null;
    String urlStr = null;
    int sleepTime = 0;
    Image image = null;
    // called only for an applet - unless called explicitely by an appliaction
    public void init() {
                   sleepTime = Integer.parseInt(getParameter("refreshTime"));
              urlStr = getParameter("jpgFile");
    // called only for an applet - unless called explicitely by an appliaction
    public void start() {
    count=(new Thread(this));
    count.start();
    // called only for applet when the browser leaves the web page
    public void stop() {
    count=null;
    public void paint(Graphics g) {
    try{
    URL location=new URL(urlStr);
    image = getToolkit().getImage(location);
    }catch (MalformedURLException mue) {
                   showStatus (mue.toString());
              }catch(Exception e){
              System.out.println("Sorry. System Caught Exception in paint().");
              System.out.println("e.getMessage():" + e.getMessage());
              System.out.println("e.toString():" + e.toString());
              System.out.println("e.printStackTrace():" );
              e.printStackTrace();
    if (image!=null) g.drawImage(image,1,1,320,240,this);
    // called each time the display needs to be repainted
    public void run() {
    while (count==Thread.currentThread()) {
    try {
    Thread.currentThread().sleep(sleepTime*1000);
    } catch(Exception e) {}
    repaint(); // forces update of the screen
    // end of PlayJpg.java
    My Html file looks like here:
    <html>
    <applet code="PlayJpg.class" width=320 height=240>
    <param name=jpgFile value="http://Localhost/playjpg/snapshot0.jpg">
    <param name=refreshTime value="1">
    </applet>
    </html>
    I only get the first frame picture for ever by my html.But the jpg file is dynamic.
    Why?
    Can you help me?
    Thanks.
    Joe

    Hi,
    Add this line inside your run() method, right before your call to repaint():
    if (image != null) {image.flush();}Hope this helps,
    Kurt.

  • Weblogic call a excel-file from URL doesn't open MSExcel but flat html

    Weblogic call a excel-file from URL doesn't open MSExcel but flat html
    Hi,
    WLS 10.3.5
    Forms 11.1.1.4
    I do migrate from AS10g to WLS 10.3.5 / Forms 11
    I get differences between FORMS 10 g / AS and FORMS 11 / WLS
    when call an excel-file with web.showdocument
    in 10g AS10g
    the call
    web.showdocumen('http://MyAS10_Server/myFormsMapping/myExcelfile.xls, _blank);
    opens a Windows-Box
    to decide
    open with ( MSExcel )
    or
    download and save as File
    in WLS 10.3.5 / FORMS 11.1.1.4
    the call with webcache Port 8090 as well as Port OHS 8888
    web.showdocumen('http://MyWLS_Server:8090/myFormsMapping/myExcelfile.xls, _blank);
    opens promptly the excel-File into the Browser as html-Format
    How to get the same way under WLS as before in AS 10g,
    config OHS ?
    regards
    get answer here :
    Weblogic: when call a excelfile from URL doesn't open MSExcel but flat html
    Edited by: astramare on Sep 12, 2011 11:59 AM

    Weblogic: when call a excelfile from URL doesn't open MSExcel but flat html

  • Download file from URL using ADF (urgent help required)

    We have the following requirement:
    On clicking a button we need to download the file present at a particular location(we have the URL).
    I have written the following in .jspx file :
    <af:commandButton  id="btn1" >
                        <af:fileDownloadActionListener contentType="text/plain; charset=utf-8" method="#{bean.getFile}"/>
    </af:commandButton>
    The corresponding method in bean is :
    public void getFile(FacesContext facesContext, OutputStream outputStream) {
    HttpServletResponse response = null;
    ServletOutputStream ouputStream = null;
    currUrl = getFileURL("ID", 281);
    response =
    (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
    try {
    ouputStream = response.getOutputStream();
    ouputStream.write(this.getFileBytes(), 0,this.getFileBytes().length);
    ouputStream.flush();
    ouputStream.close();
    } catch (IOException ioe) {
    System.out.println("IO Exception");
    public byte[] getFileBytes() {
    URLConnection urlConn = null;
    InputStream iStream = null;
    URL url;
    byte[] buf;
    int byteRead;
    try {
    url= new URL("http://hjhj:34104/test.pdf");
    urlConn = url.openConnection();
    iStream = urlConn.getInputStream();
    buf = new byte[5000000];
    byteRead = iStream.read(buf);
    if (byteRead > 0) {
    System.out.println("Downloaded Successfully.");
    return buf;
    } catch (FileNotFoundException fnfe) {
    System.out.println("File not found Exception");
    fnfe.printStackTrace();
    } catch (Exception e) {
    System.out.println("Exception:" + e.getMessage());
    e.printStackTrace();
    } finally {
    try {
    iStream.close();
    } catch (IOException e) {
    System.out.println("IO Exception");
    e.printStackTrace();
    System.out.println("File");
    return null;
    The file is opening in same window but in some encrypted format. My requirement is to :
    1. Have a pop (as in Mozilla or IE) which asks if I want to save the file or open.
    2. Depending on that the file should be opened in pdf format and not in browser same window neither in browser tab.

    Jdev version : 11.1.2.1.0
    in .jspx file : we have a button. On clicking the button file from URL should be downloaded. I have used fileDownloadActionListener in commandButton. Corresponding code :
    <af:commandButton  id="btn1" >
                        <af:fileDownloadActionListener contentType="text/plain; charset=utf-8" method="#{bean.getFile}"/>
    </af:commandButton>
    in bean class : the method corresponding to fileDownloadActionListener is :
    public void getFile(FacesContext facesContext, OutputStream outputStream) {
         HttpServletResponse response = null;
         ServletOutputStream ouputStream = null;
         response =(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
         try {
              ouputStream = response.getOutputStream();
              ouputStream.write(this.getFileBytes(), 0,this.getFileBytes().length);
              ouputStream.flush();
              ouputStream.close();
              } catch (IOException ioe) {
                   System.out.println("IO Exception");
    public byte[] getFileBytes() {
         URLConnection urlConn = null;
         InputStream iStream = null;
         URL url;
         byte[] buf;
         int byteRead;
         try {
              url= new URL("http://hjhj:34104/test");
              urlConn = url.openConnection();
              iStream = urlConn.getInputStream();
              buf = new byte[5000000];
              byteRead = iStream.read(buf);
              if (byteRead > 0) {
                   System.out.println("Downloaded Successfully.");
              return buf;   
        } catch (FileNotFoundException fnfe) {
              System.out.println("File not found Exception");
         } catch (Exception e) {
              System.out.println("IO Exception");
    The URL given in the code is for a file which can be a PDF file or an EXCEL file.
    My requirement is when i click the button:
    1. A pop should come (as in Mozilla or IE) which asks if I want to save the file or open.
    2. if i click on save file should save in a particular location.
    3. if i click on open it should open as PDF/EXCEL format and NOT in browser.
    Message was edited by: 1001638

Maybe you are looking for

  • Check box rendering problem in List.

    Hi All,             I am using list component in my app and list component allows multiple selections. I am using an itemrenderer having the checkbox and label in hbox. Rendering is working fine. but when I selected three or four items randomly using

  • JBO 25030 while inserting into JTab with jNavigationBar

    Hello, in a master/detail swing panel the insert button of the navigation bar for the detail view throws "JBO-25030: Failed to find or invalidate owning entity." - The views are connected through a view link - The Detail View is a join through severa

  • Asset history sheet (S_ALR_87011990) is not working ok

    Hello,      I have problems with the asset history sheet (S_ALR_87011990) because it doesen't shows the right amount for the totals. I chose the "Lisst assets or group totals only" check mark and the totals amounts for one asset class are not equal w

  • Internal hyperlinks within Apple Mail

    Does anyone know how to create internal hyperlinks within Apple Mail? For instance, I want to put something like "contents" at the start of an email where I can click on the title Content 1 Content 2 Content 3 to bring me to the paragraphs below Cont

  • Creating PR in Unapproved Status

    Hi All Pl let me know the steps to be followed to create Purchase Requisition in Unapproved Status in Back To Back Order Scenario. Business requirement is to create PR in unapproved status from the SO Line. We are on 11.5.10.2 and its urgent. Thanks