private static int detectTexturePackFormat(File zipfile) throws IOException {
  ZipInputStream zis=null;
  try {
    zis=new ZipInputStream(new FileInputStream(zipfile));
    boolean foundAssetsDir=false;
    boolean foundBlocksDir=false;
    boolean foundTerrainPng=false;
    ZipEntry entry=null;
    while ((entry=zis.getNextEntry()) != null) {
      String entryName=entry.getName();
      if (entryName.startsWith("assets/minecraft/"))       foundAssetsDir=true;
 else       if (entryName.startsWith("textures/blocks/"))       foundBlocksDir=true;
 else       if (entryName.equals("terrain.png"))       foundTerrainPng=true;
    }
    return foundAssetsDir ? FORMAT_1_6 : foundBlocksDir ? FORMAT_1_5 : foundTerrainPng ? FORMAT_PRE_1_5 : FORMAT_INVALID;
  }
  finally {
    if (zis != null)     zis.close();
  }
}

private static int detectTexturePackFormat ( File zipfile ) throws IOException { ZipInputStream zis = null ; try { zis = new ZipInputStream ( new FileInputStream ( zipfile ) ) ; boolean foundAssetsDir = false ; boolean foundBlocksDir = false ; boolean foundTerrainPng = false ; ZipEntry entry = null ; while ( ( entry = zis . getNextEntry ( ) ) != null ) { String entryName = entry . getName ( ) ; if ( entryName . startsWith ( "assets/minecraft/" ) ) foundAssetsDir = true ; else if ( entryName . startsWith ( "textures/blocks/" ) ) foundBlocksDir = true ; else if ( entryName . equals ( "terrain.png" ) ) foundTerrainPng = true ; } return foundAssetsDir ? FORMAT_1_6 : foundBlocksDir ? FORMAT_1_5 : foundTerrainPng ? FORMAT_PRE_1_5 : FORMAT_INVALID ; } finally { if ( zis != null ) zis . close ( ) ; } }
looks inside the given zip file to determine the format of the texture pack .
