By Alvin Alexander. Last updated: June 6, 2016
As a quick note, I use code like this in my Mac/Java/Scala applications to determine where I can put my application data files on a user’s Mac OS X filesystem:
object Global { val APP_NAME = "TypewriterFX" val SLASH = System.getProperty("file.separator") val USER_HOME_DIR = System.getProperty("user.home") val REL_APP_DATA_DIR = "Library/Application Support/com.valleyprogramming/" + Global.APP_NAME val CANON_ROOT_APP_DIR = USER_HOME_DIR + SLASH + REL_APP_DATA_DIR // Users/Al/Library/Application Support/com.valleyprogramming/Typewriter val CANON_LOG_DIR = CANON_ROOT_APP_DIR + SLASH + "Logs" // Users/Al/Library/Application Support/com.valleyprogramming/Typewriter/Logs val CANON_DEBUG_FILENAME = CANON_LOG_DIR + SLASH + Global.APP_NAME + ".log" // Users/Al/Library/Application Support/com.valleyprogramming/Typewriter/Logs/Typewriter.log val CANON_SOUNDS_DIR = CANON_ROOT_APP_DIR + SLASH + "Sounds" }
The comments show where these files end up when I run my apps on my computer.
As I’ve mentioned elsewhere on this site, I don’t use that SLASH value too often. OS X is based on Unix, and Unix systems have used the forward-slash since ~1969, and I doubt it will change any time soon.