the demo code of http://www.jroller.com/rickard/entry/a_generic_input_output_api