Problem in using URL to FTP

The result received was in http format.
How can I instruct the FTP server to give me the directory list?
My code is :
int readCount = 0;
URL url = new URL("ftp://hostname.com");
URLConnection uc = url.openConnection();
InputStream content = uc.getInputStream();
File f = new File("C:\\test.txt");
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
byte[] buf = new byte[102400];
String contentType = uc.getContentType();
while ((readCount = content.read(buf)) > 0) {
fos.write(buf, 0, readCount);
fos.close();
content.close();     

JavaWorld published an article about this topic. It is called "Java FTP client libraries reviewed" and it can be found here :
http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html
Best regards
Jean-Pierre Norguet
Jean-Pierre Norguet
JavaWorld Press
http://wasa.ulb.ac.be/jp.html

Similar Messages

  • PROBLEM while using URL in order to open a file from a servlet

    Hi,
    I am having a problem while trying to open a file from my servlet by using URL connection. Following is my code sample. what happens is when I first run my project it opens the file but after that when I rerun it again and again it sometimes opens it and sometimes not. if it can't open it it gives an error saying "the file is damaged and couldn't be repaired". I don't get any exceptions. if you guys can help me I will appreciate it so much... thanks.
    here is my code :
    URL url = new URL("http://demobcs.ibm.com:81/test.pdf");
    resp.setContentType(getContentType("http://demobcs.ibm.com:81/test.pdf"));
              ServletOutputStream sos = null;
              BufferedInputStream bis = null;
              try {
                   sos = resp.getOutputStream();
              } catch (Exception e) {
                   System.out.println("exception !!!!");
                   e.printStackTrace();
              System.out.println("burada2");
              try {
                   byte[] bytes = new byte[4096];
                   //bis = new BufferedInputStream(conn.getInputStream());
                   DataInputStream in = new DataInputStream(url.openStream());
                   //DataInputStream in = new DataInputStream(conn.getInputStream());
                   bis = new BufferedInputStream(in);
                   int j;
                   while ((j = bis.read(bytes, 0, 4096)) != -1) {
                        try {
                             sos.write(bytes, 0, 4096);
                             System.out.println("file is being read ...:");
                        } catch (Exception e) {
                             e.printStackTrace();
                   in.close();
                   bis.close();          
                   //sos.close();
              } catch (Exception e) {
                   System.out.println("exception :"+e.toString());
                   e.printStackTrace();
              }

    You are writing (<filesize> mod 4096) bytes of crap at the end of the file. Use your variable j instead for the number of bytes to write in your loop.

  • How to use URL CHIPs in Page Builder?

    Hi all,
    I have encountered a problem of using URL CHIPs in CHIP Catalog.
    I cannot find any documents on how to use the CHIPs in CHIPs Catalog of Page Builder. I just simply want to display a URL in NWBC. I suppose that there is an input in URL CHIPs for URL addresses and then the URL can display. However, it is not the case.
    I have already looked at the template of URL CHIPs (WDR_TEST_PAGE_CHIP_PROV_2) and still I don't understand how to use the URL CHIP.
    Please give me some hints on this one.
    Regards,
    Dominic

    Hi.,
    Check this article : [Integrating goole maps in WDA using page builder|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0bca5ae-3c5c-2d10-938d-a81787f59ace?quicklink=index&overridelayout=true]
    also this hlep docu : http://help.sap.com/saphelp_nw70ehp2/helpdata/en/20/361af8255f4a33a2e8441956cc8f63/content.htm
    http://help.sap.com/saphelp_tm80/helpdata/en/b1/914b8c3fb648babc568967d430a9f8/content.htm
    hope this helps u.,
    Thanks & Regards,
    Kiran

  • File to File scenario using Transport Protocol FTP  Problem

    Hi,
    my scenario is a file to file scenario using Transport Protocol FTP
    there are 3 systems involved
    a. computer 1 ( My system-source)
    b. computer 2 (XI server)
    c. computer 3 (Target system)
    I want XI to pick file from computer 1 and post it to computer 3
    I am logging on to XI server from computer 1(thro SAP GUI),
    <u><b>Sender communication  channel :</b></u>
    Transport protocol:FTP
    Messsage protocol: file
    <u><b>In FTP connection Parameters:</b></u>
    Server: computer 1 IP address
    port:21
    User name and PW---> I have given computer 1 Username and password.
    Connection mode: permanently
    Transfer mode: Binary
    Folder: C:\ftproot\output
    filename : given
    <u><b>In Receiver Communication Channel</b></u>
    Transport protocol:FTP
    Message protocol: file
    <u><b>In FTP connection Parameters:</b></u>
    Server: computer 3 IP address
    port:21
    User name and PW---> I have given computer 3 Username and password.
    Connection mode: permanently
    Transfer mode: Binary
    Put File: Use Temporary File
    Folder:
    eccserver\saploc\tmp
    filename scheme: given
    When I activate the scenario file is not getting picked from the source
    In Adapter Framework: Message says up and running No message processing now
    How to check FTP server is up and running on computer 1 (source system)and Computer 2 (XI server)?
    What could be the problem ?
    Thanks
    dushanth

    Hi
    Consider that I dont have FTP installed on my computer. According to this blog
    /people/shabarish.vijayakumar/blog/2006/08/01/along-came-a-file-adapter-mr-ftp-and-rest-of-the-gang
    I have configured.
    In sender comm channel I have given Ipaddress of computer 1 (which has a file to be picked)
    In Receiver Comm channel I have given IP address of computer 3 (in which file to be posted)
    and computer 2 is the XI server
    Computer 1 has FTP installed
    1. XI server should have FTP installed or not ? IF yes is it FTP client  or FTP server   or Guild FTP (according to the blog is enough)
    2. Computer 3 should have FTP installed or not ?
    Please help me I am really confused.
    Thanks
    dushanth

  • Problem with using new Upload to FTP Host feature...

    I tried using the "Upload to FTP Host" feature to upload to GoDaddy.com. It worked fine the first time but now I get this message:
    Error:
    Error creating folder //images. Click Resume to try again. If this problem persists, try again later.
    I tried a few times and even waited two days but I am still getting the same message. So I tried to "Export as HTML" liked I used to do and now for some reason it will not create a CSS or Scripts folder. Only an images folder.
    Also, the first time the "Upload to FTP Host" worked for some reason not all the images were there and the transition box I have is not fading smoothly from one image to the next.
    Please help!!!
    Thanks,
    Melissa

    The issue looks like it might be related to a known issue with our FTP upload client. We currently incorrectly assume the server is configured to use / as the root direcotry. We have a fix for the issue, that will be released in an upcoming update (likely to be sooner rather than later). The workaround for it is actually pretty simple though. If you login to your FTP server, you should be able to see what directory you are at, and you can use the full path there to upload successfully.
    For example, if you login using a different FTP client, you might see something like /home/users/myuser/ in the address bar. In Muse, in the directory location, if you place /home/users/myuser you will upload to the correct directory. If you want to upload to a specific directory, simply add that to the end of the directory path.
    If you are unable to upload after following the above steps, as Abhishek says, it is likely a permissions error. Try exporting first and using a third party client to upload it and let us know if you are able to do so successfully from there.

  • Problem using CLIENT_HOST to FTP files from forms 10g

    Hi,
    I'm trying to use forms 10g ODS & webutil on NT to allow a user to select a file on their machine or the network and transfer the file to a DB server. I want to transfer the file to the file system on the server NOT to a BLOB column on a table. I've used webutil (client_get_file_name) to display the dialog box and allow the user to select a file. This works fine. However, when I try to use CLIENT_HOST to FTP the selected
    to the remote server it fails. I'm issuing the following
    command from within forms:
    CLIENT_HOST('CMD /C ftp -n -s:C:\test_ftp.txt');
    Something tries to kick off and a grey area the size of a dos window flashes on to the screen for a couple of seconds but the FTP does not happen. The test_ftp.txt script is a simple ftp script that transfers one file and I know it works as I can run it successfully from DOS or NT command prompt.
    Questions:
    (1) Does anyone know how to pause the DOS window so you
    can see what is actually happening ?
    (2) Has anyone implemented FTP functionality
    successfully using CLIENT_HOST in the same way that's
    I'm trying ?
    Any help would be appreciated.
    Declan.

    Okay...
    Try this. For testing put your command in a .bat-file. In this .bat-file spool the output to a text-file. I'm not sure about the spooling syntax under Windows, check the Windows documentation for that. Like:
    ftp.bat
    start spooling to ftp.out
    cmd /c .... (your ftp commando line)
    stop spooling
    Perhaps the problem is that it doesn't find the ftp commando? Try hardcode the path like c:\windows\ftp ... etc!

  • How to use URL?

    Hi everyone,
    I have a problem constructing URL with ftp protocol. If I use:
    new URL("ftp://userName:pwd@"+ipAddress+filePath), I can get the file, but if I use
    new URL("ftp://userName:@"+ipAddress+filePath), I can't get the file. In this case, I want to connect to ipAddress without a password, but still need to provide a user name.
    If anybody can help me with this, I will be very appreciated.

    Hi benzoyl,
    I have a very similar problem.
    I want to connect to a webserver (using http),
    which requires password and username in the following
    syntax:
    http://username:[email protected]/nic/update?...
    to update a database there.
    The result is always UnknownHostException: username
    It seems, java can't handle the @ or something in that
    direction.
    When I test the query-string in the browser, it works!
    Could you already solve the problem?
    Regards,
    Markus

  • Problem in download file from FTP server

    Hi
    I want to download a file from FTP server for that i am using the apache FTP module but i am not getting how to download a file with that api i can dispaly the list of files and folders but not able to download the file or folder can any one help me in this
    Thanks
    Ninad

    Hi
    I think you miss understood something I am writing a program to download the file in Java where i have used the jakarta.apache api for that and getting problem in that bellow is the code where I have written to print the directory & file names but I don't know how to download the file
    FTPClient ftpConnection = new FTPClient();
    ftpConnection.connect(host);
    ftpConnection.login(FTPConnection.userName,FTPConnection.password);
    FTPFile fileList[] = ftpConnection.listFiles();
    for(int i=0;i<fileList.length;i++)
         System.out.println(fileList.getName());
    thanks
    Ninad

  • Time machine: An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.

    Time machine backups are failing. I've followed the instructions I found on the Time Machine troubleshooting page (http://pondini.org/TM/Troubleshooting.html) but have gotten to where I don't know what to do next.
    Sequence of events:
    The main error message is always:
    An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.
    Yesterday, I opened Disk Utility and verified the disk. Got this error:
    Error: This disk needs to be repaired using the Recovery HD. Restart your computer, holding down the Command key and the R key until you see the Apple logo. When the OS X Utilities window appears, choose Disk Utility.
    I ran Disk Utility and repaired the hard drive. Then I manually started the backup before going to bed, figuring it was going to take a long time to run. When I got up this morning, the backup had failed with the same "could be temporary" error. I checked the log, which says:
    Starting manual backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:17
    Error: (5) setxattr for key:com.apple.backupd.SnapshotState path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:2
    Deep event scan at path:/ reason:must scan subdirs|new event db|
    Finished scan
    Found 145601 files (11.88 GB) needing backup
    16.1 GB required (including padding), 620.77 GB available
    Copied Zero KB of 11.88 GB, 0 of 145601 items
    Copied 0 files (Zero KB) from volume Macintosh HD.
    Copy stage failed with error:11
    Backup failed with error: 11
    Ejected Time Machine disk image: /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle
    Ejected Time Machine network volume.
    Starting automatic backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/9F8E7957-9C50-49C3-8314-880E5203E3D9
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/
    Does anyone know what the problem is here and what I should do?
    Thanks,
    Tery

    You have repaired your boot drive (which is good) but have you repaired your time machine drive?  I don't own a Time Capsule so I don't know if disk utility can operate on it.  If it can, you should repair it as well.  You may need to erase it and start a new backup.  That happens to time machine volumes from time to time and is why people who are serious about their data never rely on a single source of backup.

  • Safari 2.0.4 , 3.0.2,3 using URL instead of IP address cookies don't work

    Seems like there is a problem when use a URL instead of ip address with cookies. I am having the same problem as posted on the site http://lists.macosforge.org/pipermail/webkit-unassigned/2007-August/047830.html

    It may be annoying to do it all again, but try all these steps:
    These are the downloads and the settings you need in order to view/hear pretty much everything that the net can throw at you: The setup described below has proved repeatedly successful on both PPC and Intel macs, but nothing in life carries a guarantee!
    Assuming you already run Tiger versions OS 10.4.9 or above (this has not yet been verified with Leopard) and have Quicktime 7.2 or above, and are using Safari 2 or 3, download and install (or re-install even if you already had them) the latest versions, suitable for your flavor of Mac, of:
    RealPlayer 10 for Mac from http://forms.real.com/real/player/blackjack.html?platform2=Mac%20OS%20X&product= RealPlayer%2010&proc=g3&lang=&show_list=0&src=macjack
    Flip4Mac WMV Player from http://www.microsoft.com/windows/windowsmedia/player/wmcomponents.mspx (Windows Media Player for the Mac is no longer supported, even by Microsoft)
    Perian from http://perian.org/
    Adobe FlashPlayer from http://www.adobe.com/shockwave/download/download.cgi?P1ProdVersion=ShockwaveFlash
    In Quicktime Preferences, under advanced, UNcheck Enable Flash, and under Mime settings/Miscellananeous only check Quicktime HTML (QHTM).
    In Macintosh HD/Library/Quicktime/ delete any files relating to DivX (Perian already has them).
    Now go to Safari Preferences/Security, and tick the boxes under Web Content (all 4 of them).
    Lastly open Audio Midi Setup (which you will find in the Utilities Folder of your Applications Folder) and click on Audio Devices. Make sure that both Audio Input and Audio Output, under Format, are set to 44100 Hz.
    Important: Now repair permissions and restart.
    The world should now be your oyster!
    You should also have the free VLC Player from http://www.videolan.org/ in your armory, as this plays almost anything that DVD Player might not.

  • Using URL Parameters in a PDF Form

    I built a form in LiveCycle Designer ES and I would like a couple of fields auto populated. The only way I could see doing this without having to purchase the LiveCycle Forms Server or another solution, is to embed the information in the URL.
    I found a blog post about it on Stefan Cameron's blog:  http://forms.stefcameron.com/2006/10/20/using-url-requests-in-pdf-forms/
    I was able to get this to work, but when I try to allow the user to save their form locally, the form information get cleared when they try to reopen it.
    I searched the NET and really couldn't find anything related to my problem.
    Does anyone have an idea about this or should I be looking at a different solution?
    Thanks,
    James

    I think that I was able to resolve this issue myself.  After opening the PDF with URL parameters, you need to manually enter data into a field before saving. After manually entering data in a field and saving, the form contains all of the data.

  • Trouble uploading website using iWeb 09 FTP

    Hello All,
    About 2 years ago I used iWeb to upload my website. At the time I had to use Website Maestro for the FTP. Recently I bought a new iMac and used iWeb 09 to change several things on my website.
    I viewed all the videos on how to upload your site using the iWeb FTP and I even used the "test connection" button and it said it was great. So I went ahead and uploaded my site and iWeb 09 confirmed that everything was fine, but it didn't change my website. The old pages were still there.
    I phoned my web hosting company (Host Papa) and they said iWeb 09 uploads the new pages to a folder in their cpanel and that I would have to log in to the cpanel and move folders around. I tried this but inside Host Papa's cpanel it was all greek to me. I phoned their help line and the guy switched all the files for me and the new pages published fine.
    My question is why can't iWeb publish my site without me having to log into their cpanel to change folders around? I noticed on the iWeb 09 publish site I had filled in one bit of information incorrectly. Where it said "Directory/Path" I typed in www/ Their help desk said I should have typed in /public_html/ If I did this would this make a difference? Would it publish directly without me having to go into their cpanel?
    Thanks for your help.
    Mike

    The old pages were still there.
    Did you try clearing your browser's cache (CommandOptionE for Safari) and reloading the page? The site and index.html file probably should be uploaded to the public_html folder in your account.
    I use WebSite Maestro and find it to be very good for uploading. You might try going back to that especially since iWeb's ftp client is posing problems. I would either try WSM or the free Cyberduck client.
    OT

  • Problem in Using XSLT

    I am facing a problem while using XSLT. The Problem is that  I have a Structue and corresponding internal table  defined as follows.
         TYPES:BEGIN OF X1,
            TW(4)        TYPE  c,
            TX           TYPE  int1,
            TY(1)        TYPE  c,
            TZ(32)       TYPE  X,
            TV(32)       TYPE  C,
            A TYPE CHAR32,
            B TYPE CHAR32,
            C TYPE CHAR32,
            D TYPE CHAR10,
            E TYPE INT4,
          END OF X1.
          DATA:INT_TABLE     TYPE TABLE OF X1.
    Now When I am Transforming this into XML using XSLT the attributes are being sorted on the field names as follows.
    &#65279;
    Is there any way for getting the attributes in the same order as we specify in the Types declaration. Please kindly help in solving this.

    Hi,
    You will most probably get an answer in the XI forum.
    https://www.sdn.sap.com/sdn/collaboration.sdn?node=linkFnode1-6&contenttype=url&content=https://Process Integration (PI) & SOA Middleware
    regards
    Aveek

  • Hi, how to use URL encoding in jsp

    hi, how to apply URL encoding in jsp for a string, could u pls suggest some ideas to use URL encoding in jsp
    thank you in advance

    hi, thnx for the reply, but my problem is to use url encoding method
    i would u like to know how to represent in jsp program i have asp code some thing like this
    href='/project/tel_number.asp?team=<%=DbRecTeam("id")%>&name=<%=Server.URLEncode(DbRec("name"))%>'
    i would like to know how replace that Server.URLEncode stmt in jsp, could u pls suggest some equivalent method for the above stmt
    thanx in advance

  • How to display the image which in KM folder using url iview

    Hi Friends
    How to display the image, which is under KM folder structur using the url iview.
    i trying using url iview url as  \document\testfolder\abc.jpg as url for the iview.
    but its now working .. so please help me how to slove this problem
    If is not the correct way then please suggest me best way to achive this.
    Thanks
    Mukesh

    Hi Mukesh,
    I think this may work,
    1, Create a HTML Layout.
        You can put your image wherever  u want with HTML Codes.
        Check this, [Article|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3915a890-0201-0010-4981-ad7b18146f81] & [Help|http://help.sap.com/saphelp_nw04/helpdata/en/cc/00c93e9b2c3d67e10000000a114084/frameset.htm]
        With this, u can use the standard KM commands also.
    2, U need to use KM Navigation iView for this rather than KM Doc iView.
    3, In the Nav iView, u can use &rndLayoutSet=nameOfUrHTMLLayout to force the view with this new layout.
    Regards
    BP

Maybe you are looking for