[1704] in java-interest
Re: help on ftp (fwd)
daemon@ATHENA.MIT.EDU (Richard Wahongan)
Thu Sep 14 16:53:29 1995
Date: Fri, 15 Sep 1995 00:58:21 +1000 (EST)
From: Richard Wahongan <n1061925@dodo.fit.qut.edu.au>
To: Java Interest <java-interest@java.Eng.Sun.COM>
-- Rick --
o----------------------+------------------------------------------------o
( Richard Wahongan | Email : n1061925@dodo.fit.qut.edu.au )
o----------------------+------------------------------------------------o
( http://www.fit.qut.edu.au/Student/~n1061925/ )
o-----------------------------------------------------------------------o
I modified my FTP program to be like this :
// FTP Test
import java.io.*;
import net.ftp.FtpClient;
import net.TelnetOutputStream;
class FTPtest
{
public static void main (String args[])
{
TelnetOutputStream tout=null;
int i;
System.out.println("Start connection...");
FtpClient client = new FtpClient("student");
System.out.println("Proxy = " + client.ftpProxyHost);
client.login("USERNAME", "PASSWORD");
client.binary();
client.get("INFO");
tout = client.put("FROM_DODO");
if (tout == null)
System.out.println("tout is null");
else
System.out.println("tout isn't null");
for (i = 1; i < 10; ++i)
tout.write(i);
System.out.println("Closing connection !!");
}
}
!!!!!!!
However, the program is still not working properly.
It only creates an empty file in the remote machine.
Am I doing the right way !
!!!!!!!
Thanks !!
> 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
>
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com