References #2387: Inlined code from commons-io so we can avoid including it as a dependency.

Change-Id: I0c30a7329362779b99241b22ff23ef86afe2bec4