FtpOutputStream或类似的标准Java [英] FtpOutputStream or similar in standard Java

查看:256
本文介绍了FtpOutputStream或类似的标准Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何可能的方式使用某种OutputStream将文件写入FTP目录,而不必先写入本地文件?

is there any possible way to write a file to a FTP directory using some sort of OutputStream without having to write a local file first?

我发现了一些能够实现这一点的第三方库,但我想知道是否有一些java标准类可以实现,我的意思是,某些类这是打包到标准的Java API。

I've found some 3rd party libraries which achieve this, but I was wondering if there is some java "standard" class that makes it possible, I mean, some class that is packaged into the standar Java API.

谢谢!!

推荐答案

URL url = new URL("ftp://user:pass@ftp.something.com/file.txt;type=i");
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // To download
OutputStream os = urlc.getOutputStream(); // To upload

这篇关于FtpOutputStream或类似的标准Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆