本文整理汇总了Java中com.enterprisedt.net.ftp.FTPTransferType类的典型用法代码示例。如果您正苦于以下问题:Java FTPTransferType类的具体用法?Java FTPTransferType怎么用?Java FTPTransferType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FTPTransferType类属于com.enterprisedt.net.ftp包,在下文中一共展示了FTPTransferType类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.enterprisedt.net.ftp.FTPTransferType; //导入依赖的package包/类
/**
* 登录服务器
*
* @return 返回登录结果 true成功 false失败
* @throws Exception
*/
private boolean connect() throws Exception {
boolean ret = false;
fc = new FTPClient();
try {
fc.setRemoteHost(this.ip);
fc.setRemotePort(this.port);
fc.setControlEncoding("UTF-8");
fc.connect();
fc.login(this.userName, this.pwd);
fc.setConnectMode(FTPConnectMode.ACTIVE);
fc.setType(FTPTransferType.BINARY);
ret = true;
return ret;
} catch (Exception e) {
throw new Exception("登录失败!");
}
}
示例2: main
import com.enterprisedt.net.ftp.FTPTransferType; //导入依赖的package包/类
public static void main(String[] args) {
// we want remote host, user name and password
if (args.length < 3) {
System.out.println("Usage: run remote-host username password");
// System.exit(1);
}
// extract command-line arguments
String host = "211.157.3.202";
String username = "root";
String password = "mabcres070907";
String filename = "C:\\UseSFTPWithoutServerValidation.java";
// set up logger so that we get some output
Logger log = Logger.getLogger(FtpService.class);
Logger.setLevel(Level.INFO);
try {
// create client
log.info("Creating SFTP client");
SSHFTPClient ftp = new SSHFTPClient();
// set remote host
ftp.setRemoteHost(host);
log.info("Setting user-name and password");
ftp.setAuthentication(username, password);
log.info("Turning off server validation");
ftp.getValidator().setHostValidationEnabled(false);
// connect to the server
log.info("Connecting to server " + host);
ftp.connect();
log.info("Setting transfer mode to ASCII");
ftp.setType(FTPTransferType.ASCII);
FTPFile[] files = ftp.dirDetails(".");
for (int i = 0; i < files.length; i++) {
log.info(files[i].toString());
}
// putGetDelete(filename, ftp);
log.info("Successfully transferred in ASCII mode");
// Shut down client
log.info("Quitting client");
ftp.quit();
log.info("Example complete");
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: setType
import com.enterprisedt.net.ftp.FTPTransferType; //导入依赖的package包/类
@Override
public void setType( FTPTransferType type ) throws IOException, FTPException {
}