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

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

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

FileUtil.getFileExtension介绍

[英]Returns the file extension of the given File or null if the file does not have an extension.
[中]

代码示例

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext.equals("gz") && !_file.getAbsolutePath().endsWith("tar.gz"))
    return false;
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

/**
 * Checks whether the given {@link Path} points to a file that has one of the given file extensions.
 * @param _p
 * @param _extensions
 * @return
 */
public static boolean hasFileExtension(Path _p, String[]  _extensions) {
  if(_p.toFile().isFile()) {
    final String ext = FileUtil.getFileExtension(_p.toFile());
    if(ext!=null) {
      for(int i=0; i<_extensions.length; i++) {
        if(ext.equalsIgnoreCase(_extensions[i])) {
          return true;
        }
      }
    }
  }
  return false;
}

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

public void setFile(File _file) throws IllegalArgumentException {
  final String ext = FileUtil.getFileExtension(_file);
  if(!ext.equals("class"))
    throw new IllegalArgumentException("Expected a class file but got [" + _file + "]");
  if(!FileUtil.isAccessibleFile(_file.toPath()))
    throw new IllegalArgumentException("Cannot open file [" + _file + "]");
  this.file = _file;
}

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

public void setFile(File _file) throws IllegalArgumentException {
  final String ext = FileUtil.getFileExtension(_file);
  if(!ext.equals("java"))
    throw new IllegalArgumentException("Expected a java file but got [" + _file + "]");
  if(!FileUtil.isAccessibleFile(_file.toPath()))
    throw new IllegalArgumentException("Cannot open file [" + _file + "]");
  this.file = _file;
}

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

@Override
public boolean canAnalyze(File _file) {
  final String ext = FileUtil.getFileExtension(_file);
  if(ext == null || ext.equals(""))
    return false;
  for(String supported_ext: this.getSupportedFileExtensions()) {
    if(supported_ext.equalsIgnoreCase(ext))
      return true;
  }
  return false;
}

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

private InputStream getArchiveInputStream() throws IOException {
  final String ext = FileUtil.getFileExtension(this.archive);
  InputStream is = null;
  try {
    if(ext.equals("gz")) {
      final GzipCompressorInputStream gzis = new GzipCompressorInputStream(new FileInputStream(this.archive));
      is =  new TarArchiveInputStream(gzis);
    } else {
      is = new ZipInputStream(new FileInputStream(this.archive));
    }
  } catch (FileNotFoundException e) {
    log.error("Cannot find Pyhton archive to analyze ["+ this.archive.getAbsolutePath() +"]", e);
  }
  return is;
}

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

/**
   * Returns the file extension of the file concerned by the change.
   * @return
   */
  public String getFileExtension() throws IllegalStateException {
    if(this.getOldFile()!=null)
      return FileUtil.getFileExtension(this.getOldFile());
    else if(this.getNewFile()!=null)
      return FileUtil.getFileExtension(this.getNewFile());
    else
      throw new IllegalStateException("Both old and new file are null");
  }
}

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

final String ext = FileUtil.getFileExtension(file.toFile());

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

if(!"class".equals(FileUtil.getFileExtension(_class_file)))
  throw new IllegalArgumentException("Expected file with extension 'class', got [" + _class_file + "]");

相关文章