For Programmers: Free Programming Magazines  


Home > Archive > Java Help > April 2007 > File









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File
Ravi

2007-04-28, 10:09 pm

import java.io.File;
class FileDemo {
public static void main(String args[]) {
File f1 = new File("/home/ravi/abc");
System.out.println("Path: "+f1.getPath());
System.out.println("Absolute path:
"+f1.getAbsolutePath());
System.out.println("Size: "+f1.length());
System.out.println("getFreeSpace:
"+f1.getFreeSpace());
System.out.println("getTotalSpace:
"+f1.getTotalSpace());
System.out.println("getUsableSpace:
"+f1.getUsableSpace());
f1.deleteOnExit();
}
}

I use GNU/Linux and the problem is that the space reported by the thre
functions is not correct. Please explain.

Joshua Cranmer

2007-04-28, 10:09 pm

Ravi wrote:
> import java.io.File;
> class FileDemo {
> public static void main(String args[]) {
> File f1 = new File("/home/ravi/abc");
> System.out.println("Path: "+f1.getPath());
> System.out.println("Absolute path:
> "+f1.getAbsolutePath());
> System.out.println("Size: "+f1.length());
> System.out.println("getFreeSpace:
> "+f1.getFreeSpace());
> System.out.println("getTotalSpace:
> "+f1.getTotalSpace());
> System.out.println("getUsableSpace:
> "+f1.getUsableSpace());
> f1.deleteOnExit();
> }
> }
>
> I use GNU/Linux and the problem is that the space reported by the thre
> functions is not correct. Please explain.
>


What is this program telling you and what do you think should be the
correct answer (and why)? The latter three functions are not guaranteed
to be able to get correct information (cf.
http://java.sun.com/javase/6/docs/a...l#getTotalSpace())...
Eric Sosman

2007-04-28, 10:09 pm

Ravi wrote:
> import java.io.File;
> class FileDemo {
> public static void main(String args[]) {
> File f1 = new File("/home/ravi/abc");
> System.out.println("Path: "+f1.getPath());
> System.out.println("Absolute path:
> "+f1.getAbsolutePath());
> System.out.println("Size: "+f1.length());
> System.out.println("getFreeSpace:
> "+f1.getFreeSpace());
> System.out.println("getTotalSpace:
> "+f1.getTotalSpace());
> System.out.println("getUsableSpace:
> "+f1.getUsableSpace());
> f1.deleteOnExit();
> }
> }
>
> I use GNU/Linux and the problem is that the space reported by the thre
> functions is not correct. Please explain.


What does it report, and why do you think it is wrong?

--
Eric Sosman
esosman@acm-dot-org.invalid
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com