4 Replies Latest reply: Apr 2, 2007 3:44 PM by 807606 RSS

    Changing Directories with FTPClient

    807606
      Hi

      I am using this code to download a file from an FTP server, which works if the file is in my local directory. My problem is that the file I need to download is not in my default directory.

      FTPClient client = new FTPClient();
      client.connect("mysever");
      client.login("username", "password");

      InputStream inputStream =client.retrieveFileStream("file i need to download");
      FileOutputStream outputStream = new FileOutputStream("c:/file.txt");
      int data;
      while((data = inputStream.read()) != -1) {
      outputStream.write(data);
      }
      inputStream.close();
      outputStream.close();

      Im sure this is an easy answer but none of my searching turned up anything useful. Thanks.