📄 ftpstreamtest.java
字号:
import cz.dhl.io.*;
import cz.dhl.ftp.*;
import java.io.*;
public class FtpStreamTest
{
public static void main(String args[])
{
/* host = ftp.netscape.com; path = pub;
* user = anonymous (default); port = 21 (default); */
FtpConnect cn = FtpConnect.newConnect
("ftp://ftp.netscape.com/");
/* Guest login ok, send your e-mail as password */
cn.setPassWord("eternity@matrix.com");
Ftp cl = new Ftp();
FtpInputStream is = null;
try
{ String line;
/* connect & login to host */
cl.connect(cn);
/* source FtpFile remote file */
FtpFile file = new FtpFile("/Welcome",cl);
System.out.println("From: " +file.toString());
/* open ftp input stream */
is = new FtpInputStream(file);
BufferedReader br = new BufferedReader
(new InputStreamReader(is));
/* read ftp input stream */
while ((line = br.readLine()) != null)
System.out.println(line);
/* close reader */
br.close();
}
catch (IOException e)
{ System.out.println(e); }
finally
{ /* close ftp input stream
* this must be always run */
if(is!=null)
try { is.close(); }
catch (IOException e) {}
/* disconnect from server
* this must be always run */
cl.disconnect(); }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -