use java file io to read correct length of files