How to create file on Linux using environment variable in the dirpath

Hi all,

I am running a Java program on a Linux server in which I read in a base directory path from the *.properties file. During processing, I build a unique file name and create a file to save data, concatenating the directory path and the file name. Works fine, except that I now need to modify this code to accept an environment variable as part of the directory path (previously it was uniquely specified). I've experimented with various ways of quoting - no luck. I'm sure there's a simple syntax to permit this, but so far I've been unable to find it.

File creation statement looks like this:

File uploadFile = new File\(baseDir \+ newFileName\);

where baseDir has been read in from the properties file and is equal to

$MYFILEDIR/reports/

The file creation is failing.

Can anyone tell me what syntax can I use in the input that would allow me to create the file in the expected directory? Thanks so much.

system.getenv() retruns the value of an environment variable. I don't think properties files are guaranteed convey the value of variables like that.

Jim,

Yes, I'd thought about System.getevn, but I was expecting to find a way to let the OS do whatever OS-specific translation was appropriate in the directory path on file creation. It's looking like that doesn't fly - maybe a shell is required to get env var translation . . . Well, I switched to using System.getenv to get the env var value and appending the rest of the directory path and that works. Thanks for taking the time to help out,

Patricia1of5