com.sap.psr.vulas.shared.util.FileUtil.getFileName()方法的使用及代码示例

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

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

FileUtil.getFileName介绍

[英]Removes path information from the argument as to return the file name.
[中]

代码示例

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Removes path information from the argument as to return the file name.
 * @param complete file path
 * @return file name
 */
public static String getFileName(String _file_path) {
  return FileUtil.getFileName(_file_path, true);
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Creates a {@link PythonId} of type {@link ConstructType#MODU} for the given py file.
 */
public static PythonId getModule(File _file) throws IllegalArgumentException {
  if(!FileUtil.hasFileExtension(_file.toPath(), new String[] { "py" })) {
    throw new IllegalArgumentException("Expected file with file extension [py], got [" + _file.toString() + "]");
  }
  final Path p = _file.toPath().toAbsolutePath();
  // Add file name w/o extension to qname components
  final String module_name = FileUtil.getFileName(p.toString(), false);
  // Search upwards until there's no __init__.py anymore, and add directory names to the qname components
  final List<String> package_name = new ArrayList<String>();
  Path search_path = p.getParent();
  while(DirUtil.containsFile(search_path.toFile(), "__init__.py") && search_path.getNameCount() > 1) {
    package_name.add(0, search_path.getFileName().toString());
    search_path = search_path.getParent();
  }
  // Create the package (if any), the module and return the latter
  PythonId pack = null;
  if(!package_name.isEmpty())
    pack = new PythonId(null, PythonId.Type.PACKAGE, StringUtil.join(package_name, "."));
  return new PythonId(pack, PythonId.Type.MODULE, module_name);
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

final String jar_name = (jar_path == null ? null : FileUtil.getFileName(jar_path));

相关文章