-2

I'm pretty new to java and I am trying to to convert this string array with hexadecimal values into an int array. I have no clue how to do it.

import java.io.*;
import java.util.*;

public class cruzD_OSpgm2
{

    public static void fileReader()
    {
        ArrayList<String> ramChipList = new ArrayList<String>();
        try 
        {
           BufferedReader br = new BufferedReader(new 
               FileReader("RAMerrors"));
           String sCurrentLine;
           while ((sCurrentLine = br.readLine()) !=null)
           {
               ramChipList.add(sCurrentLine);
           }
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }   

        String[] ramChip = new String[ramChipList.size()];
        ramChip = ramChipList.toArray(ramChip);
    }

    public static void main(String[] args)
    {
        fileReader();
    }
}

here are the 4 hex values ABCDEFABC 1A00D0000 7A0EDF301 3CDAEFFAD

chb
  • 1,727
  • 7
  • 25
  • 47
dave
  • 1

3 Answers3

0

You can just use Integer.parseInt("Array as a string", 16)

-1

new java.math.BigInteger("ABCDEFABC",16);

@See JavaDoc:

Optional
  • 4,387
  • 4
  • 27
  • 45
-1

All integer, Long, BigInteger classes have parse method which take string as input and convert it to value. Check Integer documentation java docs

Ricky
  • 155
  • 1
  • 7