I am making an applet for transferring ftp files, and I need to know the size of the local file (to resume downloading). The problem is that File.length () returns 0.
A file exists (marked with File.exists ()) and has more than 0 bytes (at least on Windows).
I don't know where to look anymore, why length () returns 0.
Here is the piece of code and the result.
long fileOffset = 0; if(localfile.exists()){ fileOffset = localfile.length(); System.out.println("The file " + localfile.getAbsolutePath() + " has " + localfile.length() +" in size"); System.out.println("Resume at: " + fileOffset); outputStream.skip(fileOffset); ftp.setRestartOffset(fileOffset); count = fileOffset; }
And the result in the console:
The file D:\test\About Downloads.pdf has 0 in size Resume at: 0
thanks
ProenΓ§a
source share