com.alibaba.citrus.util.FileUtil.getExtension()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中com.alibaba.citrus.util.FileUtil.getExtension()方法的一些代码示例,展示了FileUtil.getExtension()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.getExtension()方法的具体详情如下:
包路径:com.alibaba.citrus.util.FileUtil
类名称:FileUtil
方法名:getExtension

FileUtil.getExtension介绍

[英]取得文件路径的后缀。

  • 未指定文件名 - 返回null
  • 文件名没有后缀 - 返回null
    [中]取得文件路径的后缀。
  • 未指定文件名 - 返回null
  • 文件名没有后缀 - 返回null

代码示例

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName) {
  return getExtension(fileName, null, false);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回指定字符串<code>nullExt</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, String nullExt) {
  return getExtension(fileName, nullExt, false);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName) {
  return getExtension(fileName, null, false);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回指定字符串<code>nullExt</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, String nullExt) {
  return getExtension(fileName, nullExt, false);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName) {
  return getExtension(fileName, null, false);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, boolean toLowerCase) {
  return getExtension(fileName, null, toLowerCase);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, boolean toLowerCase) {
  return getExtension(fileName, null, toLowerCase);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, boolean toLowerCase) {
  return getExtension(fileName, null, toLowerCase);
}

代码示例来源:origin: webx/citrus

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回指定字符串<code>nullExt</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, String nullExt) {
  return getExtension(fileName, nullExt, false);
}

代码示例来源:origin: webx/citrus

public boolean isSatisfied(PipelineStates states) {
  String ext = getExtension(getRunData().getTarget(), "null", true);
  if (extensions.contains(ext)) {
    log.debug("Target extension matched: {}", ext);
    return true;
  }
  return false;
}

代码示例来源:origin: webx/citrus

public boolean isSatisfied(PipelineStates states) {
  String ext = getExtension(getRunData().getTarget(), "null", true);
  if (extensions.contains(ext)) {
    log.debug("Target extension matched: {}", ext);
    return true;
  }
  return false;
}

代码示例来源:origin: webx/citrus

public FileItem filter(String key, FileItem file) {
  if (file == null) {
    return null;
  }
  boolean allowed = false;
  // 未指定文件名 - 返回null
  // 文件名没有后缀 - 返回字符串“null”
  // 后缀被规格化为小写字母
  String ext = getExtension(file.getName(), "null", true);
  if (ext != null) {
    for (String allowedExtension : extensions) {
      if (allowedExtension.equals(ext)) {
        allowed = true;
        break;
      }
    }
  }
  if (!allowed) {
    log.getLogger().warn("Uploaded file type \"{}\" is denied: {}", ext, file.getName());
    return null;
  } else {
    return file;
  }
}

代码示例来源:origin: webx/citrus

public FileItem filter(String key, FileItem file) {
  if (file == null) {
    return null;
  }
  boolean allowed = false;
  // 未指定文件名 - 返回null
  // 文件名没有后缀 - 返回字符串“null”
  // 后缀被规格化为小写字母
  String ext = getExtension(file.getName(), "null", true);
  if (ext != null) {
    for (String allowedExtension : extensions) {
      if (allowedExtension.equals(ext)) {
        allowed = true;
        break;
      }
    }
  }
  if (!allowed) {
    log.getLogger().warn("Uploaded file type \"{}\" is denied: {}", ext, file.getName());
    return null;
  } else {
    return file;
  }
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, boolean toLowerCase) {
  return getExtension(fileName, null, toLowerCase);
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回指定字符串<code>nullExt</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName, String nullExt) {
  return getExtension(fileName, nullExt, false);
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

/**
 * 取得文件路径的后缀。
 * <ul>
 * <li>未指定文件名 - 返回<code>null</code>。</li>
 * <li>文件名没有后缀 - 返回<code>null</code>。</li>
 * </ul>
 */
public static String getExtension(String fileName) {
  return getExtension(fileName, null, false);
}

代码示例来源:origin: webx/citrus

String ext = FileUtil.getExtension(fileItem.getName(), "null", true);

代码示例来源:origin: webx/citrus

String ext = FileUtil.getExtension(fileItem.getName(), "null", true);

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

public boolean isSatisfied(PipelineStates states) {
  String ext = getExtension(getRunData().getTarget(), "null", true);
  if (extensions.contains(ext)) {
    log.debug("Target extension matched: {}", ext);
    return true;
  }
  return false;
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

public FileItem filter(String key, FileItem file) {
  if (file == null) {
    return null;
  }
  boolean allowed = false;
  // 未指定文件名 - 返回null
  // 文件名没有后缀 - 返回字符串“null”
  // 后缀被规格化为小写字母
  String ext = getExtension(file.getName(), "null", true);
  if (ext != null) {
    for (String allowedExtension : extensions) {
      if (allowedExtension.equals(ext)) {
        allowed = true;
        break;
      }
    }
  }
  if (!allowed) {
    log.getLogger().warn("Uploaded file type \"{}\" is denied: {}", ext, file.getName());
    return null;
  } else {
    return file;
  }
}

相关文章