public void setFile(final File file, final JTree tree, final NBTFrame frame) {
    this.file = file;
    try {
      final PrintWriter pw = new PrintWriter(LAST, "UTF-8");
      pw.println(file);
      pw.close();
    } catch(final IOException e) {
      e.printStackTrace();
    }
    NBTReader read = null;
    NBTCompound r = null;
    try {
      if(hasExtension(file, RegionFile.ANVIL_EXTENSION,
          RegionFile.MCREGION_EXTENSION)) {
        MapReader.clearCache();
        final MapReader mr = MapReader.getForFile(file);
        final List<ChunkInFilePosition> coords = mr.getChunks();
        final ChunkInFilePosition chunk =
            (ChunkInFilePosition) JOptionPane.showInputDialog(frame,
                "Choose the chunk to display", "Choose chunk",
                JOptionPane.PLAIN_MESSAGE, null, coords.toArray(), null);
        r = chunk != null ? mr.read(chunk) : null;
        if(r != null && hasExtension(file, RegionFile.ANVIL_EXTENSION)) {
          final Chunk c = new Chunk(r, file, chunk);
          new ChunkFrame(8.0, c, frame);
        }
        wrapZip = false;
        canSave = false;
      } else {
        read = new NBTReader(file);
        r = read.read(NBTType.COMPOUND);
        wrapZip = true;
        canSave = true;
      }
    } catch(final IOException e) {
      // do not do this!
      // try {
      // read = new NBTReader(file, false);
      // r = read.read();
      // wrapZip = false;
      // } catch (final IOException ie) {
      // ie.printStackTrace();
      // }
      e.printStackTrace();
    } finally {
      if(read != null) {
        try {
          read.close();
        } catch(final IOException e) {
          e.printStackTrace();
        }
      }
    }
    if(r != null) {
      tree.setModel(new NBTModel(r));
      frame.setTitle(file, r.hasChanged());
    }
  }