/** * Translates a relative path to a local system path. * * @param destination The path to translate. * @return The translated path. */ private String translatePath(String destination) { // Parse for variables destination = vs.substitute(destination, null); // Convert the file separator characters return destination.replace('/', File.separatorChar); }
/** * Creates an temp file in to the substitutor the substituted contents of input writes; close it * and (re)open it as FileInputStream. The file will be deleted on exit. * * @param input the opened input stream which contents should be substituted * @param substitutor substitutor which should substitute the contents of input * @return a file input stream of the created temporary file * @throws Exception */ public InputStream substituteVariables(InputStream input, VariableSubstitutor substitutor) throws Exception { File tempFile = File.createTempFile("izpacksubs", ""); FileOutputStream fos = null; tempFile.deleteOnExit(); try { fos = new FileOutputStream(tempFile); substitutor.substitute(input, fos, null, null); } finally { if (fos != null) fos.close(); } return new FileInputStream(tempFile); }