java获取ftp服务器端文件大小

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;

import sun.net.ftp.FtpClient;

@SuppressWarnings("restriction")
public class FTPUtil {
    public static void main(String[] args) throws Exception {
      FtpClient client = new FtpClient();
      client.openServer("192.168.1.12");
      client.login("username", "password");
      client.cd("/home/ganliang/");
      InputStream dis =new DataInputStream(client.list());
      BufferedReader reader = new BufferedReader(new InputStreamReader(dis));
      String s="";
      while((s = reader.readLine()) != null) {
        System.out.println(s);
      }
      if(reader!=null){
          reader.close();
      }
    }
}

你可能感兴趣的:(java,文件大小,ftp服务器端)