Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:25:19+00:00 2026-05-15T19:25:19+00:00

I’m trying to implement TMX files in Android and I was hoping someone could

  • 0

I’m trying to implement TMX files in Android and I was hoping someone could help. Based on the TMX guide, in order to get the GID’s I have to

first base64 decode the string, then gunzip the resulting data if the compression attribute is set to “gzip” as in the above example. Finally, you can read 4 bytes at a time for each GID from the beginning of the data stream until the end.

I think I’ve figured out the base64 decoding and ‘gunzip’ but the result from the code below is 27,0,0,0 repeating. I think the output is supposed to be

(0,0) (1,0) (2,0) (3,0) (0,1) (1,1) (2,1) (3,1) (0,2) (1,2) (2,2) (3,2)

Thanks!

 public static void main( String[] args )
 {
 String myString = "H4sIAAAAAAAAAO3NoREAMAgEsLedAfafE4+s6l0jolNJiif18tt/Fj8AAMC9ARtYg28AEAAA";

 byte[] decode = Base64.decodeBase64(myString);

 ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decode); 
 GZIPInputStream gzipInputStream;

 int read;
 try
 {
      gzipInputStream = new GZIPInputStream(byteArrayInputStream);

      InputStreamReader inputStreamReader = new InputStreamReader(gzipInputStream);
      BufferedReader bufferedReader = new BufferedReader(inputStreamReader, 4);

      while ( ( read = bufferedReader.read() ) != -1 )
      {
           System.out.println("read :" + read);
      }
 }
 catch (IOException e)
 {
      e.printStackTrace();
 }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:25:19+00:00Added an answer on May 15, 2026 at 7:25 pm

    Don’t use Readers for anything but character data!

    Use a DataInput to read the integers. Decorate your GZIPInputStream with a DataInputStream and use readInt.

    If the ints are little-endian, you’ll need to reverse the order of the bytes for the type. Java uses network byte order (big-endian). For integers, this can be done with Integer.reverseBytes.

    You can print the hex values using:

    System.out.format("%08x", (int) n);
    

    How to read all int values from a stream of arbitrary length:

    One mechanism would be to use the available() method which estimates the number of remaining bytes:

    byte[] ints = {0x00, 0x00, 0x00, (byte) 0xFF,
                   (byte) 0xAA, (byte) 0xBB, (byte) 0xEE, (byte) 0xFF};
    ByteArrayInputStream array = new ByteArrayInputStream(ints);
    DataInputStream data = new DataInputStream(array);
    while(data.available() > 0) {
      int reversed = Integer.reverseBytes(data.readInt());
      System.out.format("%08x%n", reversed);
    }
    

    In the general case, available() is not a reliable mechanism. But you can augment your stream with a buffer to check data availability:

      public static void main(String[] args) throws IOException {
        byte[] ints = {0x00, 0x00, 0x00, (byte) 0xFF,
                        (byte) 0xAA, (byte) 0xBB, (byte) 0xEE, (byte) 0xFF};
        ByteArrayInputStream array = new ByteArrayInputStream(ints);
        BufferedInputStream buffer = new BufferedInputStream(array);
        DataInputStream data = new DataInputStream(buffer);
        while(hasData(data)) {
          int reversed = Integer.reverseBytes(data.readInt());
          System.out.format("%08x%n", reversed);
        }
      }
    
      public static boolean hasData(InputStream in) throws IOException {
        in.mark(1);
        try {
          return in.read() != -1;
        } finally {
          in.reset();
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.