This commit is contained in:
2020-06-18 15:26:26 +08:00
parent d24ba2e3e4
commit bddb4d1243
4 changed files with 52 additions and 8 deletions

View File

@@ -69,7 +69,7 @@ public class Tools {
// 目标文件所在目录不存在
if (!destFile.mkdirs()) {
// 复制文件失败:创建目标文件所在目录失败
System.err.println("创建文件夹失败");
System.err.println("创建文件夹失败:"+destFile.getAbsolutePath());
return false;
}
@@ -122,6 +122,22 @@ public class Tools {
return copyFileToName(srcFileName, destFileName, null, overlay);
}
}
public static void copy_dir(String src,String desc){
try {
File dirSrc=new File(src);
for (File file : dirSrc.listFiles()) {
if(file.isDirectory()){
new File(desc+File.separator+file.getName()).mkdirs();
copy_dir(file.getAbsolutePath(),desc+File.separator+file.getName());
}else{
copyFile(file.getAbsolutePath(),desc,true);
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private static boolean copyDir(String dir,String dest){
try{
//System.out.println("复制文件"+dir+"到"+dest);
@@ -312,4 +328,20 @@ public class Tools {
e.printStackTrace();
}
}
public static void outError(InputStream inputStream){
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String tmp;
while ((tmp = reader.readLine()) != null) {
System.out.println(tmp);
}
reader.close();
}catch (Exception e){
e.printStackTrace();
}
}
public static boolean isWindowsRuntime(){
System.out.println(System.getProperties().getProperty("os.name"));
return System.getProperties().getProperty("os.name").toLowerCase().contains("windows");
}
}