NB: In both cases below you will have to digitally sign your applet, so that it is granted permissions to read/write from/to the file system!
If you can use external libraries, use Apache commons-io (you will have to sign these jars as well)
FileUtils.readFileToString(..)
FileUtils.writeStringToFile(..)
If you can't, you can see this tutorial.
This is for text files - but if you want to read binary files (.png for instance), you should not read it as string. Instead read it as byte[]
and use commons-codec -
encode: String base64String = new String(Base64.encodeBase64(byteArray));
decode: byte[] originalBytes = Base64.decodeBase64(string.getByte());
Base64 is a string format for storing binary data.