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

  • Home
  • SEARCH
  • 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 7684207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:58:22+00:00 2026-05-31T18:58:22+00:00

So, I’ve created a HashMap(Resource being my own creation), which each key is the

  • 0

So, I’ve created a HashMap(Resource being my own creation), which each key is the filepath for each resource. Now, let’s say I have a Resource with a filepath “mat\10wdim3.mat” in the HashMap, trying to retrieve it will fail because both hashcodes are not equal.

The hashcode in the Map for this key is: -347056295
The string I’m using to try and retrieve that resource: -2128683668

There is no hidden characters I could find in either strings. Is there any other way that the hashcodes wouldn’t match?

EDIT:

Including some sample code

Initializing in the constructor. Creating and adding the resources(The filepath is trimmed beforehand)

private Map<String, Resource> m_Files;

public ResourceManager() {
    m_Files = new HashMap<String, Resource>();
}

public Resource createResource(String filepath, byte[] contents) {
    if (filepath != null && contents != null && contents.length > 0) {          
        String extension;
        int lastIndex = filepath.lastIndexOf(".");
        Resource res = null;

        if (lastIndex == -1)
            return null;

        extension = filepath.substring(lastIndex).toLowerCase();

        // TODO: Optimize this by putting the most common at the top
        try {
            if (extension.equals(".pup"))
                res = new Puppet(contents);
            else if (extension.equals(".bm"))
                res = new Bitmap(contents);
            else if (extension.equals(".snd"))
                res = new SoundFile(contents);
            else if (extension.equals(".cmp"))
                res = new ColorMap(contents);
            else if (extension.equals(".mat"))
                res = new Mat(contents);
            else if (extension.equals(".sft"))
                res = new Font(contents);
            /*else if (extension.equals(".ai") // Normal AI
                    || extension.equals(".ai0") // Easy AI
                    || extension.equals(".ai2")) // Hard AI
                res = new AIFile(contents);*/

            if (res != null) {
                addResource(filepath, res);

                return res;
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }

    return null;
}

public void addResource(String filepath, Resource res) {
    if (filepath != null && res != null && m_Files.put(filepath, res) != null)
        System.out.println("[!] Replacing " + filepath);
}

public Resource getResource(String filepath) {
    return m_Files.get(filepath);
}

To get said resource

ResourceManager rManager = new ResourceManager();

rManager.loadGOB("C:/Documents and Settings/Unrealomega/Desktop/JKDF2/GOB/Resource/Res2.gob");

Resource res = rManager.getResource("mat\10wdim3.mat");
  • 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-31T18:58:24+00:00Added an answer on May 31, 2026 at 6:58 pm

    The problem is that you did not escape letter ‘\’ to ‘\\’;

    “mat\10wdim3.mat”.hashCode(); //-2128683668

    but if you escape letter ‘\’,you will get the follow ouput:

    “mat\\10wdim3.mat”.hashCode(); // -347056295

    So,just escape the filePath String ,when you fetch the resource from HashMap!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a text area in my form which accepts all possible characters from
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.