This is only meant for use in DualBootPatcher, but feel free to use it (at your own risk) in your own project. See the following files in https://github.com/chenxiaolong/DualBootPatcher for examples:
src/com/github/chenxiaolong/dualbootpatcher/FileUtils.java
src/com/github/chenxiaolong/dualbootpatcher/MainApplication.java