FTP downloading using Java

Hi,
My program wants the capability to download a zipped file to a client machine for offline viewing. The zipping can be done using the util.zip package. But to place the file physically on to the client machine, can I use FTP?
I know one of the options is to place the zip file somewhere in the web server and give a link from where the client can download it. But, is it possible to write the zip file physically to the client's machine?
TIA
manoj.

You can use FTP to accomplish this. There are a set of classes (open source) available to do this. Check out the following site for download and API information.
http://www.savarese.org/oro/index.html. This is the same package used by Jakarta Ant for the external FTP task.
Hi,
My program wants the capability to download a zipped
file to a client machine for offline viewing. The
zipping can be done using the util.zip package. But
to place the file physically on to the client machine,
can I use FTP?
I know one of the options is to place the zip file
somewhere in the web server and give a link from where
the client can download it. But, is it possible to
write the zip file physically to the client's
machine?
TIA
manoj.

Similar Messages

  • FTP progarm using JAVA

    I need to fetch the files from Linux server through ftp using java. I am using the following package.
    org.apache.commons.net.ftp.*
    FTPClient class has the features like makeDirctory ,disconnect and so on.
    But, FTPClient class can not be recognizable. How can I make this cass as recognizable?

    Cross-post
    http://forum.java.sun.com/thread.jspa?threadID=639588&tstart=0

  • Downloading using java applet

    i want to download some files from my own site using java. the downloadable files may be of any type. the problem is applet is not allowing me to do so. can any one guide me for this. how to download files using java applet

    Correction: an applet may only connect to the server from which it was downloaded from. localhost is on the list of forbidden machines - unless you are viewing the applet locally through a http server.
    These security restrictions can be loosened if you make the applet signed. (There is a separate forum for signed applets under the security section.)

  • Ftp connection using java

    Hi All,
    I need to upload a file through ftp connection uisng java calss. any one know please reply me
    Thanks
    K.Kalikumar

    Hi Kali,
    I have worked on similar issues sending you the code.. hope it should work. I had written a TelnetInterface class where I did all operation inside the constructor.
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.InputStream;
    import java.io.PrintStream;
    import org.apache.commons.net.telnet.TelnetClient;
    public class TelnetInterface {
         private TelnetClient telnet = new TelnetClient();
         private InputStream in;
         private PrintStream out;
         private String prompt = ">";
         private boolean isConnected ;
    public TelnetInterface(){
         public TelnetInterface(HttpServletRequest request) {
                   HttpSession session = request.getSession();
                   PropertyReader propReader = (PropertyReader)session.getAttribute("propReader");
                   String host=null,user=null,password=null,port=null;
                   int unixPort= 0;
    //                Get Unix credentials
                   if(propReader != null){
                        host=(String)propReader.getProperty("UNIX_HOST");
                        user=(String)propReader.getProperty("UNIX_UNAME");
                        password=(String)propReader.getProperty("UNIX_PWD");
                        port=(String)propReader.getProperty("UNIX_PORT");
                        unixPort = Integer.parseInt(port) ;
    //                    Connect to the specified server
                   System.out.println("Inside telnet Interface");
                   try{
                        telnet.connect(host, unixPort);
                        isConnected = true;
                        in = telnet.getInputStream();
                        out = new PrintStream(telnet.getOutputStream());
    //                    Log the user on
                        readUntil("login: ");
                        write(user);
                        System.out.println("user:"+ user);
                        readUntil("Password: ");
                        write(password);
                        System.out.println("password:"+ password);
                        sendCommand("su - loginuser");
                        su(" password");
                   }catch (IOException e) {
                        e.printStackTrace();
                        isConnected = false;     
                   }catch (Exception e){
                        e.printStackTrace();
         }

  • FTP using java API

    i saw the ftp upload an download codes in one of the previous forums...
    is it possible for a directory listing of the remote system i.e., the user can select the files which he has to download from the server . is it possible to do that using java api without any third party package???

    Type java ftp to google and you'll find a couple of dozen Java FTP client implementations.
    One of them comes with Sun's JDK, sun.net.ftp.FtpClient. It's in the "sun" package hierarchy, which means it's unsupported, undocumented and subject to change without notice.
    What I've done myself is grab Sun's FtpClient and copy it to one of my own packages; that way it won't suddenly change. (I did that when it had a couple of dodgy changes between using active/passive/extended passive modes.)

  • Jar file downloaded using FTP gets damaged

    Hi people, Am working on a solution that implements an auto update of an application developed using Java. I am using Apache commons package for downloading the updated JAR file from an FTP site. Once I have the new JAR file on my local machine, I double click it and I get the following error. Invalid or corrupt jarfile C:\FIDS\FIDS.jar When I use a different FTP client to download my JAR file, the file works well when double clicked. What could be happening on my JAR file. Thanks and regards.

    tdulce_aboo wrote:
    I know that FTP is not the best solution, however, sometimes we are bound by what the client has in place.I know, it wasn't trying to attack you, it was just a general rant. FTP is so common and when it's the only thing available you obviously have to use it. I just don't understand those who actively enable it on their server and suggest (or even require) its use.
    What is your suggestion,that I use http? or ?That depends on what it's used for.
    My normal one-stop replacement would be SFTP: based on SSH, secure, authenticated, tunnelable, uses a single connection, doesn't do stupid "translations" of the transfered data, ...

  • Ftp using java... urgent!!!!

    im student
    i did a program....but it doesn't work....i dont know what is the problem....please..i hope that someone can helpme and correct my mistake....
    thank you so much!!!!!
    import sun.net.*;
    import java.net.*;
    import sun.net.ftp.*;
    import java.io.*;
    import sun.net.TelnetInputStream;
    class FtpClientes{
         public static void main(String args[]){
              try{
              int ch;
    byte[] buffer = new byte[4096];
    int bytes_read;
              System.out.println("comienza el ftp");
              FtpClient ftp=new FtpClient();
    ftp.openServer("ftp.eafit.edu.co");
    ftp.login("myname","mypassword");
              System.out.println("buscando directorio.....");
    TelnetInputStream lista =ftp.list();
    System.out.println("buscando directorio.....");
    while( (ch = lista.read()) != -1 )
    System.out.print((char)ch);
    ftp.cd("EAFIT/encuesta_planeacion/encuesta_final.doc");
    System.out.println("buscando directorio.....");
    ftp.binary();
              System.out.println("cogiendo archivo.....");
    TelnetInputStream in = ftp.get("/EAFIT/encuesta_planeacion/encuesta_final.doc");
              System.out.println("leyendo el archivo.....");
              BufferedReader d = new BufferedReader(new InputStreamReader(in));
              while(d.readLine().length()>0){
                   System.out.println(d.readLine());
              System.out.println("preparados para copiar el archivo.....");
    FileInputStream fis = new FileInputStream("/EAFIT/encuesta_planeacion/encuesta_final.doc" );
    TelnetOutputStream ts = ftp.put("/EAFIT/encuesta_planeacion/encuesta_final.doc");
              System.out.println("copiando el archivo.....");
              while( (fis.read(buffer)) != -1 ) {
                   ts.write(buffer);
    System.out.println("cerrando todo lo que alguna vez abri.....");
              ts.close();
              fis.close();
         ftp.closeServer();
         }catch(Exception e){}

    Hi BatemanA,
    Can you please clarify more? I have not used FTP so much so I don't know how to "upload" a file using this FTP URL.
    Thank you.
    Maulin
    The ftp protocol handlers supports uploading and
    download ing aswell as directory and other ftp
    operations that can be encoded in the URL (see RFC
    1738).

  • Access mirror site using java, download files and other information?

    Hi, I have 2 nodes/servers on the system both running webservers and having the same interface, but at a time user will access one node at a time from their browser, but this interface will be able to allow the user to get information from the both the nodes. the information that the user can get is DB stored as well as files on the disk of either node.
    i can manage the DB, cuz there is nothing to it, but how do I get files from the other node?
    currently any files/web documents are all stored in a application directory of the web root and protected by htaccess i believe, so when a user logs on to node one he can access all plain text/binary files along with web content since the web server authorizes the user to access anything in that dir. but at the same time from the same session I want to be able to access files in a mirror site using the same username and password and not having him to enter it again. the username/pass combo is replicated on both the servers, it this possible?
    currently i use the http password protection provided by apache to access one node, but can i use the same session on another machine with the same credentials?
    If this is not possible how can i do this programatically using java? can i do can "ls" on the directory i want on another server and display the list to the user and then when he clicks on that file name i fetch it from the backup/mirror server and have him save it using http or ftp?
    It would be great if we can get a solution to this.
    Thank you very much in advance.
    Ankur

    If you install the web server on different machines, It is possible to share the informations between them.

  • Use java code to start  ftp server in Windows

    I am writing an application using java to start the FTP server on Windows system Could anybody give me an idea on how to start?

    http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/developer/onlineTraining/Programmin
    /BasicJava1/compile.html
    http://java.sun.com/learning/new2java/index.html
    http://javaalmanac.com
    http://www.jguru.com
    http://www.javaranch.com
    Bruce Eckel's
    Thinkin
    in Java
    Joshua Bloch's
    [url=http://www.amazon.co.uk/exec/obidos/Author=Bloch,%
    0Josh]Effective Java
    Bert Bates and Kathy Sierra's
    [url=http://www.amazon.com/exec/obidos/tg/detail/-/0596
    04656?v=glance]Head First Java
    lol. That's one way to start.
    But really, why would you want to start an ftp server from java?? You should use the right tool for whatever job you need to accomplish and you can set up windows to automatically start the server when it boots.
    majinda might say: it si lkie thrownig chickne at palm to knock datse to ground. bettre to let donkey kick tree.
    But if you insist, you'll probably need JNI.

  • How to download video files using java

    hi,
    i am designing a download manager using java. Although i am able to download html pages and images as of now, i am facing problems while downloading the video files. Can somebody please guide me as to how to do this.
    Thanks in advance,
    Arun

    All types of data should be downloaded in same way. What is your problem: exception or something else? Post here.

  • I have a question related to patch download using ftp which was working in

    Hi,
    I have a question related to patch download using ftp which was working in Classic Metalink.
    ftp updates.oracle.com allowed to download patches before but now it says the following.
    $ ftp updates.oracle.com
    Connected to updates.oraclegha.com.
    421-*********************** Downtime Notice ************************
    421-
    421-This service was retired as of November 06, 2009.
    421-
    421-****************************************************************
    421
    Is there a way to download patches now using command prompt. I couldn't see category for metalink in forums hence posted here.
    Regards,
    Nagendra Chillale

    Enter the following command where username and password are your My Oracle Support login and password and filename is the patch file name that you copied from the Properties window::
    wget http-user=username http-password=password no-check-certificate output-document=filename "http://updates.oracle.com/Orion/Download/download_patch/<filename>"
    For example, to download patch 7154429 for Linux where the patch file name is p7154429_10204_Linux-x86.zip, enter:
    wget http-user=[email protected] http-password=password no-check-certificate  output-document=p7154429_10204_Linux-x86.zip "http://updates.oracle.com/Orion/Download/download_patch/p7154429_10204_Linux-x86.zip"
    My Oracle Support FAQ ID 747242.5
    Regards,
    Nagendra Chillale
    Edited by: user12023326 on Dec 16, 2009 11:43 AM

  • I just downloaded the Java software update and now certain programs aren't loading that use Java?

    So I downloaded the new softeware update and now my programs that use Java won't load. Does anyone know what I can do.

    Due to the extreme unpredictability of the Flashback Trojan, that was constantly changing (and a new variant that's been detected and seems to be worse), Apple decided to play it safe just in case the revised Java code was still vulnerable. So, Java is disabled by default for applets and must be manually enabled as needed (with the warning about possible vulnerability).
    So, head on over to Java Preferences, in Utilities, and enable the thing as needed. Disable when no longer in use for security's sake. BTW, if you enable but don't use Java in awhile, it is configured to self-disable for the same reason.

  • Downloading images and audio file using java

    Dear All
    I have a directory on my webserver which contains images,audio files and many other data files.
    I want to download all the file but the problem is when i download image and save it, it is not viewable. I dont want to use Image class as i may have to downlaod audio files too. Please guis which stream shouldi open to download any kind of content using same code.
    Thanks in advance. And if u have some example please let me know
    Regards
    Jafery

    downloading images and audio file using java -------------------------------
    how to write it back to dataoutputstremI don't understand what you are talking about.
    Server: DataOutputStream -> Client: DataInputStream -- the two is a pair.

  • This will stump you! I can not download the PDF stored on my FTP site using Internet Explorer

    I can not download the PDF stored on my FTP site using Internet Explorer, but I can with Chrome, Safari, FireFox etc. Error message: museutils.js Code: 0
    My page: http://creditunionone.org/applications---forms.html
    and this page also: http://petfoodpantryokc.org/get-assistance.html
    Please Help! I am getting 20-30 submissions from members. clients/ customers stating they can not download the forms.
    addition: Pop Up says: Windows Internet Explorer  Errors on this webpage might cause it to work incorrectly. A Security Problem Occured   | museutils.js  Code: 0
    URI: http://www.creditunionone.org/scripts/1.1/museutils.js?110351884

    The links still aren't updated for any of the pages. You need to update the links like this for eg.
    Incorrect link - http://[email protected]/forms/membershipcardstaticpdf.pdf
    Correct link - http://creditunionone.org/forms/membershipcardstaticpdf.pdf
    Select "Download Form" within the Accordion in Design mode and update the links as above. Preview the site in browser (IE) before publish.
    Thanks,
    Vinayak

  • How to access MS Exchange Server Mail and download attachment using Java ??

    Hi guys,
    I need to develop a program to access my inbox from MS Exchange Server and also download the attachment using Java language !! Any example code or any site which got tutorial on this ? Thanks !!

    Here is a java file that connects to a users exchange account, reads all messages, and writes the attachment to the file system.
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class TestNew {
    public static void main (String args[]) throws Exception {
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getInstance(props, null);
    // Get the store
    Store store = session.getStore("imap");
    // Connect to store
    store.connect(host, username, password);
    // Get folder
    Folder topFolder = store.getDefaultFolder();
    Folder folder = literature.getFolder("newFolder");
    folder.open(Folder.READ_WRITE);
    Message[] msg = folder.getMessages();
    for(int i = 0; i < msg.length; i++){
    Address[] from = msg.getFrom();
    String subject = msg[i].getSubject();
    Object o = msg[i].getContent();
    if (o instanceof MimeMultipart) { //attachements available?
    MimeMultipart mm = (MimeMultipart) o;
    int mmCount = mm.getCount();
    for (int m = 0; m < mmCount; m++) { // for each part
    Part part = mm.getBodyPart(m);
    String disposition = part.getDisposition();
    if ((disposition != null) && ((disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE)))) {
    InputStream is = null;
    File tempFile = new File("D:\\TEMP\\mailtest\\" + part.getFileName());
    FileOutputStream fos = null;
    try {
    fos = new FileOutputStream(tempFile);
    is = part.getInputStream();
    int byteCount = 0;
    byte[] bytes = new byte[128];
    while ( (byteCount = is.read(bytes, 0, bytes.length)) > -1) { //use full read() method for GZIPInputStream to be treated correctly
    fos.write(bytes, 0, byteCount);
    finally {
    try {
    if (fos != null)
    fos.close();
    catch (IOException ioe) {}
    try {
    if (is != null)
    is.close();
    catch (IOException ioe) {}
    System.out.println("Content: " + o);
    System.out.println(from[0].toString());
    System.out.println(subject);

Maybe you are looking for