Java Root Directory Get getRoot()

Here you can find the source of getRoot()

Description

get Root

License

Open Source License

Declaration

public static File getRoot() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static File getRoot() {

        System.out.print("Detecting OS... ");

        final String name = System.getProperty("os.name").toLowerCase();
        File root;//from w  ww  .  ja v a 2 s.  c  o m

        if (name.contains("win"))
            root = new File(System.getenv("APPDATA") + File.separator + ".minecraft");
        else if (name.contains("mac"))
            root = new File(
                    System.getProperty("user.home") + File.separator + "Library/Application Support/minecraft");
        else if (name.contains("nix") || name.contains("nux") || name.contains("aix"))
            root = new File(System.getProperty("user.home") + File.separator + ".minecraft");
        else
            root = null;

        System.out.println(name);

        return root;

    }
}

Related

  1. getRoot()
  2. getRoot()
  3. getRoot()
  4. getRoot()
  5. getRoot()
  6. getRoot(File child)
  7. getRoot(File file)