[1646] in java-interest
Re: help on ftp
daemon@ATHENA.MIT.EDU (Jonathan Payne)
Tue Sep 12 15:37:43 1995
Date: Tue, 12 Sep 1995 09:40:17 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: n1061925@dodo.fit.qut.edu.au, java-interest@java.Eng.Sun.COM
class FTPtest
{
public static void main (String args[])
{
FtpClient client = new FtpClient("student.fit.qut.edu.au");
System.out.println("Proxy = " + client.ftpProxyHost);
client.login("myusername", "mypassw");
client.ascii();
client.list();
client.get("remote_file"); // ascii file
client.put("local_file");
System.out.println("Closing connection !!");
}
}
You are just completely misunderstanding the way FtpClient works.
Since the documentation sucks (my fault) I will explain here.
client.get() returns an InputStream which when you read is the
contents of the file. If you want to store that file some place
locally, then you must open a file for writing locally, and write
everything you read from the client.get() to your output file.
In other words, client.get("name") is like
FileInputStream in = new FileInputStream("name");
except it opens a file on an ftp server.
And client.put("name") is like
FileOutputStream out = new FileOutputStream("name")
except it stores it on the ftp server.
client.list() returns an InputStream which when read contains the
output from listing the directory on the ftp server. Saying
client.list() and not looking at the return value is sort of a waste
of time.
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com