/** * Locates the NetBeans cache directory. * This may be used to store pure performance caches - files which could be safely deleted, * since they would be automatically recreated on demand. * Each module is responsible for using sufficiently unique filenames within this directory. * {@code $userdir/var/cache/} is used as a default when {@link #getUserDirectory} is configured. * As a final fallback, a location in the system temporary directory will be returned. * @return a directory location (never null but need not yet exist) * @see #getCacheSubdirectory * @see #getCacheSubfile */ public static synchronized /*@NonNull*/ File getCacheDirectory() { Places places = Lookup.getDefault().lookup(Places.class); if (places != null) { File cache = places.findCacheDirectory(); if (cache != null) { return cache; } } File userdir = getUserDirectory(); if (userdir != null) { return new File(new File(userdir, "var"), "cache"); } return new File(System.getProperty("java.io.tmpdir"), "nbcache"); }