1 Replies Last post: Aug 3, 2005 1:57 PM by Serge Piletsky  
Andr? Tessier   1 posts since
Apr 24, 2006
Currently Being Moderated

Aug 2, 2005 10:03 PM

FileInfo.getSize() return wrong value

Hi,

 

here's some code

 

FileInfo fileInfo = new FileInfo("c:
myfile.txt");

System.out.println("fileInfo.toString() " + fileInfo.toString());

System.out.println("fileInfo.getFileName() " + fileInfo.getFileName());

System.out.println("fileInfo.getLastModified() " + fileInfo.getLastModified());

System.out.println("fileInfo.getSize() " + fileInfo.getSize());

System.out.println("fileInfo.attributes() " + fileInfo.getAttributes());

 

Here's the output

 

fileInfo.toString() c:\myfile.txt

fileInfo.getFileName() c:\myfile.txt

fileInfo.getLastModified() 0

fileInfo.getSize() 0

fileInfo.attributes() 0

 

The last three values are wrong.

 

Anything wrong with this code ?

 

Thank you

 

Andre Tessier

 

 

 

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
1. Aug 3, 2005 1:57 PM in response to: Andr? Tessier
Re: FileInfo.getSize() return wrong value

Hi,

 

The FileInfo class is not supposed to be used in such way, because it is rather the storage of a file information then the utility for retrieving it.

 

You can find the source code for this class in the sources of WinPack library. This class is used by the FileSystemWatcher class, in both its (Win9xWatcherStrategy and WinNTWatcherStrategy) strategies for storing the file system information.

 

To retrieve a file information (such as lastModified etc.) you can use the standard Java java.io.File class. If you need to get the extended file information, which is not provided by the File class, you can use the com.jniwrapper.win32.io.FileSystem class from WinPack library. It allows to get/set all file attributes, get free disk space and so on.

 

 

 

More Like This

  • Retrieving data ...