码迷,mamicode.com
首页 > 编程语言 > 详细

java服务器备份(复制)

时间:2019-03-18 10:28:19      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:this   write   i++   taf   exist   pat   wpa   stat   ddr   

 

public ResponseResult serverBackup (String[] datypeid)throws IOException{
ResponseResult rr = new ResponseResult();
Properties props = new Properties();
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("jdbc.properties");
props.load(inputStream);
String oldrootPath = props.getProperty("material");
String rootPath = props.getProperty("backupAddress");
List<String> affixIdList = affixService.getAffixId(datypeid);
List<String> affixPathList = new ArrayList<>();
for(int i = 0;i< affixIdList.size();i++){
String path = affixService.getAffixPath(affixIdList.get(i));
if(path != null){
affixPathList.add(path);
}
}
for(int j = 0 ; j < affixPathList.size();j++){
FileInputStream fis
= new FileInputStream(new java.io.File(affixPathList.get(j)));
BufferedInputStream bis
= new BufferedInputStream(fis);
String newPath = affixPathList.get(j).replace(oldrootPath,rootPath);
java.io.File newFile = new java.io.File(newPath);
if( !newFile.getParentFile().exists()) {
newFile.getParentFile().mkdirs();
}
FileOutputStream fos
= new FileOutputStream(newFile);
BufferedOutputStream bos
= new BufferedOutputStream(fos);
int d = -1;
while((d = bis.read())!=-1){
bos.write(d);
}
bis.close();
bos.close();
}
rr.setMessage("success");
rr.setState(1);
return rr;
}

---恢复内容结束---

java服务器备份(复制)

标签:this   write   i++   taf   exist   pat   wpa   stat   ddr   

原文地址:https://www.cnblogs.com/ytsbk/p/10550595.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!