java.util.zip.ZipFile.getName()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(129)

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

ZipFile.getName介绍

[英]Gets the file name of this ZipFile.
[中]获取此ZipFile的文件名。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Returns archive name or <code>null</code> if entry is not inside archived file.
 */
public String getArchiveName() {
  if (zipFile != null) {
    return zipFile.getName(); 
  }
  return null;
}

代码示例来源:origin: robolectric/robolectric

@Override
 public String toString() {
  if (isFromZip) {
   return "FileMap{" +
     "zipFile=" + zipFile.getName() +
     ", zipEntry=" + zipEntry +
     '}';
  } else {
   return "FileMap{" +
     "mFileName='" + mFileName + '\'' +
     '}';
  }
 }
}

代码示例来源:origin: oblac/jodd

/**
 * Returns archive name or <code>null</code> if entry is not inside archived file.
 */
public String archiveName() {
  if (zipFile != null) {
    return zipFile.getName();
  }
  return null;
}

代码示例来源:origin: ronmamo/reflections

@Override
  public String toString() {
    return jarFile.getName();
  }
}

代码示例来源:origin: org.reflections/reflections

@Override
  public String toString() {
    return jarFile.getName();
  }
}

代码示例来源:origin: ronmamo/reflections

public String getPath() {
  return jarFile.getName();
}

代码示例来源:origin: spotbugs/spotbugs

@Override
  public String toString() {
    return zipFile.getName();
  }
}

代码示例来源:origin: org.reflections/reflections

public String getPath() {
  return jarFile.getName();
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public String getURL() {
  return zipFile.getName();
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public String getPathName() {
  return zipFile.getName();
}

代码示例来源:origin: pmd/pmd

@Override
public String getNiceFileName(boolean shortNames, String inputFileName) {
  // FIXME: this could probably be done better
  return zipFile.getName() + ":" + zipEntry.getName();
}

代码示例来源:origin: pmd/pmd

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + ((zipEntry == null) ? 0 : zipEntry.getName().hashCode());
  result = prime * result + ((zipFile == null) ? 0 : zipFile.getName().hashCode());
  return result;
}

代码示例来源:origin: pmd/pmd

@Override
public String toString() {
  return new StringBuilder(ZipDataSource.class.getSimpleName())
      .append('[')
      .append(zipFile.getName())
      .append('!')
      .append(zipEntry.getName())
      .append(']')
      .toString();
}

代码示例来源:origin: neo4j/neo4j

private ZipEntry getSingleSuitableEntry( ZipFile zipFile ) throws IOException
  {
    List<String> unsuitableEntries = new ArrayList<>();
    Enumeration<? extends ZipEntry> enumeration = zipFile.entries();
    ZipEntry found = null;
    while ( enumeration.hasMoreElements() )
    {
      ZipEntry entry = enumeration.nextElement();
      if ( entry.isDirectory() || invalidZipEntry( entry.getName() ) )
      {
        unsuitableEntries.add( entry.getName() );
        continue;
      }
      if ( found != null )
      {
        throw new IOException( "Multiple suitable files found in zip file " + zipFile.getName() +
            ", at least " + found.getName() + " and " + entry.getName() +
            ". Only a single file per zip file is supported" );
      }
      found = entry;
    }
    if ( found == null )
    {
      throw new IOException( "No suitable file found in zip file " + zipFile.getName() + "." +
          (!unsuitableEntries.isEmpty() ?
              " Although found these unsuitable entries " + unsuitableEntries : "" ) );
    }
    return found;
  }
}

代码示例来源:origin: apache/kylin

public void accept(ZipFile archive, ZipEntry zipEntry) {
  check(archive.getName(), zipEntry.getName().replace('\\', '/'));
}

代码示例来源:origin: pmd/pmd

@Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    ZipDataSource other = (ZipDataSource) obj;
    if (zipEntry == null) {
      if (other.zipEntry != null) {
        return false;
      }
    } else if (!zipEntry.getName().equals(other.zipEntry.getName())) {
      return false;
    }
    if (zipFile == null) {
      if (other.zipFile != null) {
        return false;
      }
    } else if (!zipFile.getName().equals(other.zipFile.getName())) {
      return false;
    }
    return true;
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Opens zip entry or plain file and returns its input stream.
 */
public InputStream openInputStream() {
  if (zipFile != null) {
    try {
      inputStream = zipFile.getInputStream(zipEntry);
      return inputStream;
    } catch (IOException ioex) {
      throw new FindFileException("Input stream error: '" + zipFile.getName()
          + "', entry: '" + zipEntry.getName() + "'." , ioex);
    }
  }
  try {
    inputStream = new FileInputStream(file);
    return inputStream;
  } catch (FileNotFoundException fnfex) {
    throw new FindFileException("Unable to open: " + file.getAbsolutePath(), fnfex);
  }
}

代码示例来源:origin: Sable/soot

public boolean selectCompilationUnit(String canonicalName) throws IOException {
  ZipFile zipFile = null;
  boolean success = false;
  try{
    zipFile = new ZipFile(file);
    String name = canonicalName.replace('.', '/'); // ZipFiles always use '/' as separator
    name = name + fileSuffix();
    if(set.contains(name)) {
      ZipEntry zipEntry = zipFile.getEntry(name);
      if(zipEntry != null && !zipEntry.isDirectory()) {
        is = new ZipEntryInputStreamWrapper(zipFile,zipEntry);
        age = zipEntry.getTime();
        pathName = zipFile.getName();
        relativeName = name + fileSuffix();
        fullName = canonicalName;
        success = true;
      }
    }
  } finally {
    if(zipFile != null && !success)
      zipFile.close();
  }
  return success;
}

代码示例来源:origin: oblac/jodd

/**
 * Opens zip entry or plain file and returns its input stream.
 */
public InputStream openInputStream() {
  if (inputStream != null) {
    return inputStream;
  }
  if (zipFile != null && zipEntry != null) {
    try {
      inputStream = zipFile.getInputStream(zipEntry);
      return inputStream;
    } catch (IOException ioex) {
      throw new FindFileException("Input stream error: '" + zipFile.getName()
        + "', entry: '" + zipEntry.getName() + "'." , ioex);
    }
  }
  if (file != null) {
    try {
      inputStream = new FileInputStream(file);
      return inputStream;
    } catch (FileNotFoundException fnfex) {
      throw new FindFileException("Unable to open: " + file.getAbsolutePath(), fnfex);
    }
  }
  throw new FindFileException("Unable to open stream: " + name());
}

代码示例来源:origin: robolectric/robolectric

ZipFileRO zipFileRO = ZipFileRO.open(zip_handle_.zipFile.getName());
ZipEntryRO entry;
entry = zipFileRO.findEntryByName(name);

相关文章