• git解决空文件夹无法提交


    improt java.io.*;
    public
    class Gitsvn { public static final String GITSVN = ".keep"; private static void check(File path) throws Exception { File[] files = path.listFiles(); if (files.length == 0) { System.out.printf("+ %s/.keep ", path.getAbsolutePath()); mark(path.getAbsolutePath()); } else { if (files.length != 1 || !files[0].getName().equals(GITSVN)) { for (int i = 0; i < files.length; i++) { if (files[i].getName().equals(GITSVN)) { System.out.printf("- %s ", files[i].getAbsolutePath()); files[i].delete(); } if (files[i].isDirectory()) { try { check(files[i]); } catch (Exception e) { } } } } } } private static void clear(File path, String target) throws Exception { File[] files = path.listFiles(); for (int i=0; i<files.length; i++) { if(files[i].getName().equals(target)) { System.out.printf("- %s ", files[i].getName()); files[i].delete(); } else if (files[i].isDirectory()) { try { clear(files[i], target); } catch (Exception e) { } } } } public static void mark(String path) { File file = new File(path + "/" + GITSVN); try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { String home = System.getProperty("user.dir"); File file = new File(home); try { if(args.length==2 && args[0].equals("-clean")) { clear(file, args[1]); } else { check(file); } } catch (Exception e) { e.printStackTrace(); } } }
  • 相关阅读:
    c# 无边框窗体显示任务栏菜单(系统菜单)
    C# 任务栏的相关信息
    C# 获取屏幕尺寸
    C# winform 中的Form 源码
    C# datagridview 的属性及事件
    C# datagridview 中添加下拉框,并绑定selectedindexchanged事件
    C# 键盘事件
    Struts2的国际化
    Struts2类型转换器
    Struts2的运行流程以及关键拦截器介绍
  • 原文地址:https://www.cnblogs.com/zhizou/p/11643455.html
Copyright © 2020-2023  润新知