In the java project i am working on, some portion of the project was written previously by someone else in C and now i need to write the same in Java.

There is a statement in C code for printing to a file:

fprintf(ff, "%04X ", image[y*width+x]);

Firstly i am not sure about the meaning of %04X. I think it means that if image[i] has length five or more then print only leftmost four chararacters. To do the same in Java i thought about masking the value using and operation

 image[i] & 0xFFFF

Can someone please tell me the correct meaning of %04X and how to do the same in Java? Thanks.

Edit
Report