用Java 6编写FTP客户端

发布于 2024-10-29 20:29:14 字数 114 浏览 0 评论 0原文

我想给自己写一个小项目——FTP客户端。 我知道如何使用 GUI、Socket 和 Socket。 ServerSocket 用于 TCP 通信。 我请你告诉我关于实现 FTP 客户端我需要更多了解什么... 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小霸王臭丫头 2024-11-05 20:29:14

首先,您需要阅读 RFC。实施最常见的操作后,使用至少一台良好的 FTP 服务器测试您的客户端。规范中有一些内容很容易出错。然后,将您编写的内容与其他实现进行比较。前段时间,我写了一个 我的 H2 数据库项目的 FTP 客户端

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.

樱花细雨 2024-11-05 20:29:14

标准 Java 中内置了相当多的内容(注意,不是 JAVA,它不是缩写词)。

可能就是这么简单

    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
        }

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
        }
℉絮湮 2024-11-05 20:29:14

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文