문제

I'm trying to make my program save its state in the location set by %APPDATA% when the user is using Windows. However, System.getProperty("temp.dir"); does not return that. How do I get the value of the %APPDATA% variable in Windows, for the purpose of state saving?

도움이 되었습니까?

해결책

Use System.getenv()

System.getenv("APPDATA")

But I think

System.getProperty("user.home") 

should be preferred even though it's not exactly the same thing because it is more portable.

다른 팁

APPDATA is a Windows specific environment variable that gives you the location where application specific data is stored, so if you are not looking to write platform independent code, you can just do System.getenv("APPDATA");

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top