发布网友 发布时间:2022-04-22 14:52
共1个回答
热心网友 时间:2023-10-03 14:46
如此类似也 \x0d\x0aimport java.net.*; \x0d\x0aimport java.io.*; \x0d\x0a \x0d\x0apublic class FtpConn \x0d\x0a{ \x0d\x0a public static void main(String [] args)throws Exception \x0d\x0a { \x0d\x0a URL u=new URL("ftp://ppmm:1111@localhost/read1.txt"); \x0d\x0a URLConnection urlconn=u.openConnection(); \x0d\x0a BufferedReader br=new BufferedReader(new InputStreamReader(urlconn.getInputStream())); \x0d\x0a String line; \x0d\x0a while(null!=(line=br.readLine())) \x0d\x0a { \x0d\x0a System.out.println(line); \x0d\x0a } \x0d\x0a } \x0d\x0a} \x0d\x0aftp://ppmm:1111@localhost/read1.txt \x0d\x0a其中localhost是ftp server地址 \x0d\x0appmm是用户名 \x0d\x0a1111是密码 \x0d\x0a 匿名用户不用写用户名和密码如 \x0d\x0aftp://localhost/read1.txt \x0d\x0a就可以了