Lets say the input to my Java code is a jpeg file. How can i verify it before starting process that the input is having a valid extension. Sometimes the user upload a pdf file with extension modified to a jpeg, thus crashing the code.
There is a point of magic number with each file. But is there any alternative to solve this problem.