My java file got messed up. It has some binary encoding according to this site: http://lajm.eu/emil/encoding/. It says it has: application/octet-stream; charset=binary
So how is my java file suddenly encoded in binary? And more important, how can I recover my code?

You can check your file encoding by going to
edit->set encoding. see what does it say. Before you panic also be sure to restart Eclipse. It sometimes happens that strange characters are shown, but usually a restart fixes it.EDIT As for how can you restore a version of your file:
Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history.(see here). You can find your file in:.metadata\.plugins\org.eclipse.core.resources\.historyof your workspace. Hopefully this will help you.EDIT 2 Ah actually the file there is ugly looking binary, but at least is stored. You can try from Eclipse: select your file -> right click -> replace with -> local history.