java 文件上传目录_Java实现上传文件到服务器指定目录的方法

Java实现上传文件到服务器指定目录的方法

发布时间:2020-08-03 10:49:31

来源:亿速云

阅读:74

作者:小猪

这篇文章主要讲解了Java实现上传文件到服务器指定目录的方法,内容清晰明了,对此有兴趣的小伙伴可以学习一下,相信大家阅读完之后会有帮助。

前言需求

使用freemarker生成的静态文件,统一存储在某个服务器上。本来一开始打算使用ftp实现的,奈何老连接不上,改用jsch。毕竟有现成的就很舒服,在此介绍给大家。

具体实现

引入的pom

ch.ethz.ganymed

ganymed-ssh3

262

com.jcraft

jsch

0.1.55

建立实体类

public class ResultEntity {

private String code;

private String message;

private File file;

public ResultEntity(){}

public ResultEntity(String code, String message, File file) {

super();

this.code = code;

this.message = message;

this.file = file;

}

public String getCode() {

return code;

}

public void setCode(String code) {

this.code = code;

}

public String getMessage() {

return message;

}

public void setMessage(String message) {

this.message = message;

}

public File getFile() {

return file;

}

public void setFile(File file) {

this.file = file;

}

}

public class ScpConnectEntity {

private String userName;

private String passWord;

private String url;

private String targetPath;

public String getTargetPath() {

return targetPath;

}

public void setTargetPath(String targetPath) {

this.targe

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值