dcsimg
get the file size
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   UPUL_JAYALATH
Posted On:   Wednesday, April 10, 2002 01:48 AM

i am developing a file transfering software in unix environment, and using com.enterprisedt.net.ftp.FTPClient class. i use


File f = new File("/data2/dump/ftp/file1.txt");


long size=(long)f.length()/1024;


to get the file size. but it wont give the result, could you please help me in this case

Re: get the file size

Posted By:   Thomas_Hackel  
Posted On:   Wednesday, April 10, 2002 05:06 AM

the code you wrote should be ok... but when the file does not exist, f.length() will return 0L. so first use something like this:
if (f.exists()){size=f.length();}
and allways(!) use File.seperator for the slash/blackslash. if NOT your code is NOT portable...
About | Sitemap | Contact