`
hkliya
  • 浏览: 83881 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java登录ftp上传文件

阅读更多
FtpClient fc = new FtpClient(hostIP, 21);
fc.login(userName, pwd);
fc.binary();
TelnetOutputStream tos = fc.put(newfilename);// 服务器上保存的文件名
InputStream is = new FileInputStream("d:\\11.jpg");// 本地文件路径
byte[] bytes = new byte[1024];
while (true) {
	int len = is.read(bytes);
	if (len == -1) {
		break;
	}
			
	tos.write(bytes);
}
tos.close();
fc.closeServer();

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics