Oz Molaim
Oz Molaim

Reputation: 2136

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

Upvotes: 2

Views: 2402

Answers (3)

Thomas Mueller
Thomas Mueller

Reputation: 50127

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.

Upvotes: 1

Paweł Dyda
Paweł Dyda

Reputation: 18662

You might want to know that some libraries exist, i.e. 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.

Upvotes: 0

Jim Blackler
Jim Blackler

Reputation: 23169

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:[email protected]/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
        }

Upvotes: 0

Related Questions