Java - File getFreeSpace difference between Mac and Windows -


i trying free space nas, mac , windows return different values. use java.io.file , method getfreespace.

mac outcome, incorrect:

39.13465499... gb

windows outcome, correct:

4134.864555... gb

my code:

    private static string multimediafolder;     private static long freediskspace;   public static void main(string[] args) {      if (system.getproperty("os.name").equals("mac os x")){         multimediafolder = "/volumes/multimedia/movies/hd";     } else if (system.getproperty("os.name").substring(0, 7).equals("windows")){         multimediafolder = "\\\\qnap\\multimedia\\movies\\hd";     }      freediskspace = new file(multimediafolder).getfreespace();     double sizeingigabyte = (double) freediskspace / 1024 / 1024 / 1024;       system.out.println(sizeingigabyte);  } 

the paths different, point @ same folder. why mac version way different windows version?

i've got answer. there 2 differences, saw in post above me.

linux returns 4326416688 <- kilobytes.

mac (just linux) returns 4326416688 <- kilobytes too.

windows returns bigger number 4429798060032 <- bytes.

this explains why windows value correct.

the code going use now:

private static string multimediafolder; private static long freediskspace; private static double sizeingigabyte;   public static void main(string[] args) {     if (system.getproperty("os.name").equals("mac os x")){        multimediafolder = "/volumes/multimedia/movies/hd";        freediskspace = new file(multimediafolder).getfreespace();        sizeingigabyte = (double) freediskspace / 1024 / 1024;    } else if (system.getproperty("os.name").substring(0, 7).equals("windows")){        multimediafolder = "\\\\qnap\\multimedia\\movies\\hd";        freediskspace = new file(multimediafolder).getfreespace();        sizeingigabyte = (double) freediskspace / 1024 / 1024 / 1024;    }     system.out.println(sizeingigabyte); } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -