Re: getting the file size from ftp server
Friday, December 6, 2002 11:07 AM
One easy way is to first issue an ls command.
For eg., if the name of the file is nohup.out
ls -l nohup.out
-rw-r--r-- 1 prash ibsg 202353 Dec 5 18:18 nohup.out
So the fifth column would be the file size. Use a string tokenizer on this line. I think you should find the same behaviour/output in all unix flavours.
I hope this helps
PS: URLConnection.getContentLength() reads form the HTTP Response Header and gives you the ContentLength. Also you will not always get the content length. It needs to be configured on the server that the Content Length is to be sent in the HTTP Response Header.