Before your "Download file" action, add a "Set a variable" action. In the action's configuration change the "Script" to return the desired URL string:
// Get some user input from some screen's input field.
String userInput = (String)context.getVariable("sometextbox");
// Call your custom code with user input and return a url
String url = com.mycompany.getDownloadFileUrl(userInput);
// Set it to the runtime variable.
return url;
Set the "Variable" property to a recognizable name.
Then, go back to your "Download file" action and click the arrow that appears if you click within the entry field for "URL".
Click insert runtime variable -> Bound variables and click the variable you created in the earlier step.