Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { private static File mapsDir; public static File getSaveMapDir() { if (mapsDir != null) { return mapsDir; } File userHome = new File(System.getProperty("user.home")); File userMaps = new File(userHome, "maps"); if (!userMaps.isDirectory() && !userMaps.mkdirs()) { // if it does not exist and i cant make it throw new RuntimeException("can not create dir " + userMaps); } mapsDir = userMaps; return userMaps; } }