i have a file that contains hexadecimal values and i want to convert them to int
how do u do that exactly??
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class CacheSimulation
{
public static void main(String args[])
throws IOException
{
int hexAdd [] = new int [32]; //array to store the vallues
Scanner diskScanner = new Scanner (new File ("addressfile.txt")); //file containing the hexadecimal values
for (int positionNum = 0; positionNum < 32; positionNum++)
{
hexAdd[positionNum] = diskScanner.nextLine(); // <--- is there a different way of reading hexadecimal values from this file,as ints wont work.???????
}
System.out.println("Position Number\tHexadecimal Address");
for (int positionNum = 0; positionNum < 32; positionNum++)
{
System.out.print(positionNum);
System.out.print("\t");
System.out.println(hexAdd[positionNum]);
}
}
}