On the Java API
Posted by Nat Tuck
Apparently in Java you can’t just read a file. First you have to create a FileOpenerFactory which has a createFileOpener() method, which returns a FileOpener, which has an openFile() method. The openFile() method returns nothing, but then you can call the getOpenedFile() method to get a File object. You can’t actually read from a File object though…
First you need to implement the InputStreamFactory abstract interface, instantiate your new class, and call the createInputStream() method. But you can’t actually use the resulting InputStream object yet. InputStreams are an abstraction that know nothing about files. So you have to use it to construct a FileInputStream class - which takes your File and InputStream objects. Only then, once you have your FileInputStream can you pass it to a FileInputStreamReader and get a FileInputData object out of it. If you wanted that FileInputData to be a string… well, I’ll cover that in my next blog post.
