Java tutorial
//package com.java2s; import java.io.File; public class Main { /** * @return a File path stored in the given environment variable, or null if none exists. */ private static File getFileFromEnvironmentVariable(String environmentVariable) { File file = null; try { String fileEnvPath = System.getenv(environmentVariable); if (fileEnvPath != null && !fileEnvPath.trim().equals("")) { file = new File(fileEnvPath); } } catch (SecurityException ignore) { } return file; } }