jar中的文件上传-jar中的路径获取

FtpClient ftp = new FtpClient ();

ftp.setDataTimeOut(10*1000);

ftp.connect(ip);

ftp.login(name,pwd);

ftp.setFileType(DTP.BINARY_FILE_TYPE);

ftp.setControlEncoding("GBK");

ftp.enterLocalPassiveMode();

String dir = ftp.printWorkingDirectory();

String filePath = "/config/test.sh";  //config前面的‘/’不能省略

String uploadPath = dir + filePath ;

InputStream istream= this.getClass().getResourceAsStream(filePath );

ftp.storeFile(uploadPath ,istream);

//释放资源

你可能感兴趣的:(学习文档)