move some code into new class FileUtil