Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to get the size of the file

807591Mar 24 2008 — edited Mar 24 2008
Hi All,

I want to get the size of the file in terms of bytes. I used the following code it returns the value in long how can get it in bytes

import java.io.File;

public class ServerBackupCheck {

public static void main(String args[]){

File f = new File("C:/Program Files/Apache Software Foundation/Tomcat 5.5");
System.out.println(f.isDirectory());
System.out.println(f.getTotalSpace());


}

}

output:
--------

true
20964163584

regards,
Maheshwaran Devaraj
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2008
Added on Mar 24 2008
12 comments
438 views