commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Hauck <maili...@vbgames.ch>
Subject Re: Commons / Net tutorial
Date Mon, 23 Jun 2003 09:58:13 GMT
And another email from me...I also got uploading working:

    private void up()
    {
        FTPClient ftp = new FTPClient();
       
        try
        {
            ftp.connect("domain");
            ftp.login("user", "pass" );
           
            ftp.changeWorkingDirectory( "/public_html" );
            ftp.setFileType(ftp.BINARY_FILE_TYPE);
            File file = new File("img.gif");
           
            FileInputStream in = new FileInputStream(file);
           
            ftp.storeFile("img.gif",in);
           
            in.close();
           
            ftp.logout();
            ftp.disconnect();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }

mike

Michael Hauck wrote:

> It's me again! ;)
>
> I think there is an error in the ftp example code. You don't set the 
> type (ftp.type(ftp.BINARY_FILE_TYPE);) so all downloaded files, except 
> text files are corrupt. After setting this it works fine. I will now 
> try to upload some files.
>
> mike
>
> Steven Haines wrote:
>
>> Hi All,
>>
>> Your question leads to a request that I have for the
>> group: I have written four articles that I put in the
>> Java Reference Guide on InformIT.com on the Commons /
>> NET classes. I already posted one on Telnet, FTP (only
>> showing download - sorry Michael), and SMTP, with the
>> final of the four on NNTP going up next Friday.
>> So Michael, take a look at www.informit.com and go to
>> the Java Reference Guide to see if my tutorials and
>> sample code help. And to the rest of you, can you
>> check out the articles and tell me if there is
>> anything that you would like changed.. I update the
>> guide every week with new content, but because I am a
>> user of these classes and not a developer of them, I
>> only had the Javadoc and an understanding of the
>> underlying protocols to work with and could very well
>> have made mistakes..
>>
>> Thanks so much and I hope that these articles are
>> useful for your users. Feel free to link to the site
>> if you think others would benefit. There is a link
>> from the resources section of the articles back to the
>> Commons/NET website.
>>
>> Steven Haines
>>
>>
>> --- Michael Hauck <mailings@vbgames.ch> wrote:
>>  
>>
>>> Hi everyone,
>>>
>>> I have just downloaded commons / net and it looks
>>> very powerful.I have played with the FTPClient class a little and 
>>> managed
>>> to connect to a FTP server and list all files there. I have however
>>> problems getting an further from there. Is there any documentation 
>>> about
>>> this project? I got the Java Docs but they aren't always very helpful.
>>> What I want to do next is to send a file (an image) to the server and
>>> get another one from the same server. Can anyone give me some hints on
>>> how to do this? Uploading and downloading simple text files works
>>> fine.
>>>
>>> Thanks!
>>>
>>> mike
>>>
>>>
>>>
>>>   
>>
>> ---------------------------------------------------------------------
>>  
>>
>>> To unsubscribe, e-mail:
>>> commons-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail:
>>> commons-user-help@jakarta.apache.org
>>>
>>>   
>>
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> SBC Yahoo! DSL - Now only $29.95 per month!
>> http://sbc.yahoo.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>>  
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>




Mime
View raw message