Reading a remote file using Java

前端 未结 7 1533
礼貌的吻别
礼貌的吻别 2020-12-06 04:28

I am looking for an easy way to get files that are situated on a remote server. For this I created a local ftp server on my Windows XP, and now I am trying to give my test a

7条回答
  •  臣服心动
    2020-12-06 05:32

    I have coded a Java Remote File client/server objects to access a remote filesystem as if it was local. It works without any authentication (which was the point at that time) but it could be modified to use SSLSocket instead of standard sockets for authentication.

    It is very raw access: no username/password, no "home"/chroot directory.

    Everything is kept as simple as possible:

    Server setup

    JRFServer srv = JRFServer.get(new InetSocketAddress(2205));
    srv.start();
    

    Client setup

    JRFClient cli = new JRFClient(new InetSocketAddress("jrfserver-hostname", 2205));
    

    You have access to remote File, InputStream and OutputStream through the client. It extends java.io.File for seamless use in API using File to access its metadata (i.e. length(), lastModified(), ...).

    It also uses optional compression for file chunk transfer and programmable MTU, with optimized whole-file retrieval. A CLI is built-in with an FTP-like syntax for end-users.

提交回复
热议问题