Windows服务器上运行一个获取图片的程序,获取图片采用的是FTP方式;

准备条件:

Linux服务器上创建一个FTP的用户:ftppic

这个账号要有权限才可以,然后编写Windows端代码:

public static boolean downFile(Stringurl,intport, Stringusername,
Stringpassword, StringremotePath, StringfileName,Stringpath
) {
booleansuccess= false;
FTPClientftp= new FTPClient();
intreply;
try{
ftp.connect(url,port);
ftp.login(username,password);
//文件类型为二进制文件
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
reply= ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
returnsuccess;
}
//本地模式
ftp.enterLocalPassiveMode();
ftp.changeWorkingDirectory(remotePath);
FTPFile[]fs= ftp.listFiles();
for(FTPFileff: fs) {
if(ff.getName().equals(fileName)) {
FilelocalFile= new File(path+ff.getName());
OutputStream is= new FileOutputStream(localFile);
ftp.retrieveFile(ff.getName(),is);
is.close();
}
}
ftp.logout();
success= true;
}catch(SocketExceptione) {
e.printStackTrace();
}catch(IOExceptione) {
e.printStackTrace();
}finally{
if(ftp.isConnected()) {
try{
ftp.disconnect();
}catch(IOExceptione) {
e.printStackTrace();
}
}
}
return success;
}

亲测好使。

Windows服务器从Linux服务器上以FTP形式获取图片的更多相关文章

  1. Windows操作系统远程Linux服务器传输文件方法(以EasyDSS云平台、EasyNVR上传部署为例)

    本文转自博客:https://blog.csdn.net/black_3717/article/details/79769406 问题背景: 之前给客户部署我们一款EasyDSS云平台(配合EasyN ...

  2. 在windows下远程访问linux服务器

    在网络性能.安全性.可管理性上,Linux有着其他系统无法比拟的强大优势,而服务器对这些方面要求特别高,因此Linux常常被用来做服务器使用.而当我们需要维护linux服务器的时候,就需要远程访问li ...

  3. windows 映射samba Linux服务器,输入正确的账号密码却提示“ 指定的网络密码不正确

    重启Linux samba服务也没用,重启Linux和windows系统也没用,急!!! 最佳答案 linux中要添加对应的系统用户和samba用户useradd titiansmbpasswd -a ...

  4. [转]Linux Ubuntu上架设FTP

    Linux Ubuntu上架设FTP http://www.blogjava.net/stonestyle/articles/369104.html 操作系统:ubuntu (GNU/Linux) 为 ...

  5. linux下的ssh工具之,本地上传到linux服务器and Linux服务器文件另存为本地。非sftp工具。

    首先,当你只有一个ssh工具可以连接linux,但你有想把文件在 linux 和windows(本地)直接的切换.其实可以的: 本文参考 1.将本地的文件,放到ssh远程的linux服务器上: 首先要 ...

  6. Windows定时任务下载linux服务器批量文件到本地

    编写批文件 1.1 编写main.bat文件 E: cd logs ftp -n -s:"E:\logs\mget.bat" 1.2 编写mget.bat文件 open ip地址 ...

  7. 同步windows时间到linux服务器

    输入date -R 查看系统时间 输入命令  ntpdate time.windows.com 同步windows时间到linux

  8. Linux Ubuntu上架设FTP

    操作系统:ubuntu (GNU/Linux) 为了在机子上架设ftp服务器,我们需要安装ftp服务器软件.Linux下具有代表性的ftp服务器软件有Wu-FTP,ProFTP和Vsftp.Wu-FT ...

  9. 云服务器 ECS Linux 服务器修改时区的两种方式

    在云服务器 ECS Linux 系统中,以 Centos6.5 为例,可以通过如下两种方式,修改系统时区: 可以使用命令 tzselect,修改时区.操作示例: [root@localhost ~]# ...

随机推荐

  1. U3D层的运用

    在操作 LayerMask 时常令一些初学者摸不着头脑下面简单说一下层的开关方法:1.首先引入'|'.'&'.'~'的概念与(交集):10000001 & 10000100 == 10 ...

  2. 用Linux完成Oracle自动物理备份

    https://blog.csdn.net/24024846/article/details/115292

  3. HDU 5790 Prefix(Hash + 主席树)

    题目链接  Prefix 题意  给定一个字符串序列,求第$l$个字符串到第$r$个字符串之间有多少个不同的前缀 强制在线 考虑$Hash$ 首先把所有前缀都$hash$出来,按顺序组成一个长度不超过 ...

  4. SpringMVC (<context:include-filter>和<context:exclude-filter>的使用)

    eg: 1.现在给定一个项目包的结构: com.yk.controller com.yk.service 2.在SpringMVC.XML有以下的配置: <!--扫描@controller注解- ...

  5. [原创][FPGA]时钟分频之奇分频(5分频)

    0. 简介 有时在基本模块的设计中常常会使用到时钟分频,时钟的偶分频相对与奇分频比较简单,但是奇分频的理念想透彻后也是十分简单的,这里就把奇分频做一个记录. 1. 奇分频 其实现很简单,主要为使用两个 ...

  6. make makefile cmake qmake都是什么,有什么区别

    原文:https://www.zhihu.com/question/27455963 作者:玟清链接:https://www.zhihu.com/question/27455963/answer/36 ...

  7. luogu P2066 机器分配

    题目背景 无 题目描述 总公司拥有高效设备M台,准备分给下属的N个分公司.各分公司若获得这些设备,可以为国家提供一定的盈利.问:如何分配这M台设备才能使国家得到的盈利最大?求出最大盈利值.其中M≤15 ...

  8. eclipse代码不能自动提示的问题解决

    步骤如下:window->Preferences->Java->Editor->content assist 替换输入成: 普通:[.abcdefghijklmnopqrstu ...

  9. android toolbar 假标题居中

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar_top" android:layout_height= ...

  10. Understand the Business Domain

     Understand the Business Domain Mark Richards EFFECTivE SoFTWARE ARCHiTECTS understand not only tec ...