简体   繁体   中英

Write FTP client with Java 6

I want to write a small project for myself - FTP client. I know to work with GUI, Socket & ServerSocket for TCP communication. I ask you to tell me what I need more to know for implemening FTP client... Thanks

First, you need to read the RFC. After implementing the most common operations, test your client with at least one good FTP servers. There are a few things in the spec that are easy to get wrong. Then, compare what you wrote with other implementations. Some time ago, I wrote an FTP client for my H2 Database project .

There's a fair amount built into standard Java (note, not JAVA, it's not an acronym).

It could be this simple

    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.URL;
    import java.net.URLConnection;

    // ....

        try {
            URL url = new URL("ftp://user:pwd@ftp.example.com/test.txt;type=i");
            URLConnection connection = url.openConnection();
            InputStream inputStream = connection.getInputStream();
            OutputStream outputStream = connection.getOutputStream();

            // ... do something useful
        } catch (IOException ex) {
          // report the error
        }

You might want to know that some libraries exist, ie Apache Commons Net . Apart from that you might want to look at NIO for some novel approach to network communication. Not saying anything about character encodings (for ASCII transfer you might need it), called Charset incorrectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM