Depends on your location.
In the EU it is specifically permitted (article 6 EU software convention) to "reverse engineer file formats for the purpose of interoperability"
In general it's hard to prevent someone reading a file format, there have been examples where you are prohibeted from writing a file because the format contains patented technology (if software patents are allowed in your country). This was the case with GIF for a number of years.