Good example. Suggest to use Apache's Common FTP library.