zoukankan      html  css  js  c++  java
  • Spring_source_thinking01

    在写代码的时候,如果发现传入的参数为空的时候,

    需要写一个Assert的类notNull方法抛出IllegalArgumentException

    public ClassPathResource(String path, ClassLoader classLoader) {
    Assert.notNull(path, "Path must not be null");
    String pathToUse = StringUtils.cleanPath(path);
    if (pathToUse.startsWith("/")) {
    pathToUse = pathToUse.substring(1);
    }
    this.path = pathToUse;
    this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
    }

    如果在StringUtils.cleanPath(path);的时候直接用if来判断就可以了

    public static String cleanPath(String path) {
    if (path == null) {
    return null;
    }
    String pathToUse = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR);

  • 相关阅读:
    批量重命令文件名称的几种方式
    SecureCRT常用快捷键
    ipv4地址从最后一位按步长递增
    win32
    GDI根据位图和透明度创建蒙版
    git bash的一些使用
    win32
    win32
    win32
    QT
  • 原文地址:https://www.cnblogs.com/handsome1013/p/5403323.html
Copyright © 2011-2022 走看看