I need to read an integer from a non-text file in Java. Here is the equivalent code in C
unsigned int MagicNumber;
int fd = open("MyFile", O_RDONLY);
int rc = read(fd, &MagicNumber, 4);
What is the equivalent in Java?
This does NOT work for me (it produces different results than the C code):
FileInputStream fin = new FileInputStream("MyFile");
DataInputStream din = new DataInputStream(fin);
int MagicNumber = din.readInt();