File f = new File(save_path+File.separator + resouce_id+".zip"); FileInputStream fis = new FileInputStream(f); String resource_size = ""; DecimalFormat df = new DecimalFormat("#.##"); double resourcesize = (double)((double)fis.available()/1024); if((double)((double)fis.available()/1024)>1000) { resource_size =df.format((double)((double)fis.available()/1024/1024))+"MB"; } else { resource_size =df.format((double)((double)fis.available()/1024))+"KB"; }