I need to add a user profile variable in java, apparently %userprofile% does not work. when I try and enter this into the directory towards the bottom of the code it does not accept it. however I can echo my %userprofil% in command line
userprofile+"\Downloads\file.txt");
String System.getenv(String var)
so
String userprofile = System.getenv("USERPROFILE");
Then manipulate as desired (e.g. append the rest of your path...)
Alternatively, get the whole environment with Map<String,String> System.getenv()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With