public NBTFileReader(String path)
        {
            this.path = path;

            FileStream stream = null;
               // GZipStream gzip = null;
            BinaryReader reader = null;

            try
            {

                stream = new FileStream(this.path, FileMode.Open, FileAccess.Read);
               // gzip = new GZipStream(stream, CompressionMode.Decompress);
                reader = new BinaryReader(stream);

                //file must start with a tag compound, whose tag type is 10
                byte tagType = reader.ReadByte();

                if (tagType != TagCompound.TagType)
                {
                    throw new InvalidTagException("Tag type at the beginning of the file must be 10");
                }
                else
                {
                    compound = new TagCompound();
                    compound.read(reader);
                }
            }
            catch (InvalidTagException)
            {
                throw;
            }
            catch (IOException exception)
            {
                throw new FailedReadException(exception.Message, exception);
            }
            catch (Exception exception)
            {
                throw new FailedReadException(exception.Message, exception);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

              /*  if (gzip != null)
                {
                    gzip.Close();
                }*/

                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
        public NBTFileReader(String path)
        {
            this.path = path;

            FileStream stream = null;
            // GZipStream gzip = null;
            BinaryReader reader = null;

            try
            {
                stream = new FileStream(this.path, FileMode.Open, FileAccess.Read);
                // gzip = new GZipStream(stream, CompressionMode.Decompress);
                reader = new BinaryReader(stream);

                //file must start with a tag compound, whose tag type is 10
                byte tagType = reader.ReadByte();

                if (tagType != TagCompound.TagType)
                {
                    throw new InvalidTagException("Tag type at the beginning of the file must be 10");
                }
                else
                {
                    compound = new TagCompound();
                    compound.read(reader);
                }
            }
            catch (InvalidTagException)
            {
                throw;
            }
            catch (IOException exception)
            {
                throw new FailedReadException(exception.Message, exception);
            }
            catch (Exception exception)
            {
                throw new FailedReadException(exception.Message, exception);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                /*  if (gzip != null)
                 * {
                 *    gzip.Close();
                 * }*/

                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
        public static List<Tag> readData(BinaryReader reader)
        {
            bool completed = false;
            List<Tag> compound = new List<Tag>();

            while (!completed)
            {
                byte tagType = reader.ReadByte();

                //Console.WriteLine("TagType: " + Util.getTypeName(tagType));

                switch (tagType)
                {
                    case 0:
                        completed = true;
                        break;
                    case 1:
                        TagByte tagByte = new TagByte();
                        tagByte.read(reader);
                        compound.Add(tagByte);
                        break;
                    case 2:
                        TagShort tagShort = new TagShort();
                        tagShort.read(reader);
                        compound.Add(tagShort);
                        break;
                    case 3:
                        TagInt tagInt = new TagInt();
                        tagInt.read(reader);
                        compound.Add(tagInt);
                        break;
                    case 4:
                        TagLong tagLong = new TagLong();
                        tagLong.read(reader);
                        compound.Add(tagLong);
                        break;
                    case 5:
                        TagFloat tagFloat = new TagFloat();
                        tagFloat.read(reader);
                        compound.Add(tagFloat);
                        break;
                    case 6:
                        TagDouble tagDouble = new TagDouble();
                        tagDouble.read(reader);
                        compound.Add(tagDouble);
                        break;
                    case 7:
                        TagByteArray tagByteArray = new TagByteArray();
                        tagByteArray.read(reader);
                        compound.Add(tagByteArray);
                        break;
                    case 8:
                        TagString tagString = new TagString();
                        tagString.read(reader);
                        compound.Add(tagString);
                        break;
                    case 9:
                        TagList tagList = new TagList();
                        tagList.read(reader);
                        compound.Add(tagList);
                        break;
                    case 10:
                        TagCompound tagCompound = new TagCompound();
                        tagCompound.read(reader);
                        compound.Add(tagCompound);
                        break;
                    default:
                        throw new InvalidTagException("An invalid tag type: " + tagType + ", was found while parsing a TAG_Compound");
                }
            }

            return compound;
        }
        public static List <Tag> readData(BinaryReader reader)
        {
            bool       completed = false;
            List <Tag> compound  = new List <Tag>();

            while (!completed)
            {
                byte tagType = reader.ReadByte();

                //Console.WriteLine("TagType: " + Util.getTypeName(tagType));

                switch (tagType)
                {
                case 0:
                    completed = true;
                    break;

                case 1:
                    TagByte tagByte = new TagByte();
                    tagByte.read(reader);
                    compound.Add(tagByte);
                    break;

                case 2:
                    TagShort tagShort = new TagShort();
                    tagShort.read(reader);
                    compound.Add(tagShort);
                    break;

                case 3:
                    TagInt tagInt = new TagInt();
                    tagInt.read(reader);
                    compound.Add(tagInt);
                    break;

                case 4:
                    TagLong tagLong = new TagLong();
                    tagLong.read(reader);
                    compound.Add(tagLong);
                    break;

                case 5:
                    TagFloat tagFloat = new TagFloat();
                    tagFloat.read(reader);
                    compound.Add(tagFloat);
                    break;

                case 6:
                    TagDouble tagDouble = new TagDouble();
                    tagDouble.read(reader);
                    compound.Add(tagDouble);
                    break;

                case 7:
                    TagByteArray tagByteArray = new TagByteArray();
                    tagByteArray.read(reader);
                    compound.Add(tagByteArray);
                    break;

                case 8:
                    TagString tagString = new TagString();
                    tagString.read(reader);
                    compound.Add(tagString);
                    break;

                case 9:
                    TagList tagList = new TagList();
                    tagList.read(reader);
                    compound.Add(tagList);
                    break;

                case 10:
                    TagCompound tagCompound = new TagCompound();
                    tagCompound.read(reader);
                    compound.Add(tagCompound);
                    break;

                default:
                    throw new InvalidTagException("An invalid tag type: " + tagType + ", was found while parsing a TAG_Compound");
                }
            }

            return(compound);
        }