Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endian Conversion #2

Open
gatis opened this issue Jun 28, 2016 · 0 comments
Open

Endian Conversion #2

gatis opened this issue Jun 28, 2016 · 0 comments

Comments

@gatis
Copy link

gatis commented Jun 28, 2016

Hi

I was not able to get tha Java code to work until I spotted Endian conversion in similar project used here : http://svn.codingteam.net/baggle/baggle-solver/src/net/inouire/baggle/solver/Dawg.java

After slightly changing initialization (endianConversion ) - this worked for me:

    public Dawg(String inputfile) throws IOException {

        try
           {      
            DataInputStream dawgDataFile = new DataInputStream(new BufferedInputStream(new FileInputStream(inputfile)));
            int numberOfNodes = endianConversion(dawgDataFile.readInt());
            units = new int[numberOfNodes];

            for (int x = 0; x < numberOfNodes; x++) {
                    units[x] = endianConversion(dawgDataFile.readInt());
            }
            dawgDataFile.close();
           }
           catch ( IOException iox )
           {
             iox.printStackTrace();
           }
    }

    private int endianConversion(int thisInteger) {
        return ((thisInteger & 0x000000ff) << 24) + ((thisInteger & 0x0000ff00) << 8) + ((thisInteger & 0x00ff0000) >>> 8) + ((thisInteger & 0xff000000) >>> 24);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant