Java Stream wants to return only failure list I have an object delivery template, which I want to delete based on a name. String array which contains delivery template name is taken as an input parameter. I use Java Stream to iterate the list. Please find the code below. 

    public static List&lt;String&gt; deleteDeliveryTemplates(String... deliveryTemplateNames) {
    List&lt;String&gt; failureList = new ArrayList&lt;String&gt;();
    Stream&lt;String&gt;deliveryTemplateNamesStream= Stream.of(deliveryTemplateNames);
     deliveryTemplateNamesStream.forEach(deliveryTemplateName -&gt;{
        try
        {
            deleteDeliveryTemplate(deliveryTemplateName);
        } catch (Exception e)
        {
            failureList.add(deliveryTemplateName);
        }
    });
    return failureList;
}


Is there a better way in JAVA 8 to return the failure list using stream. For example: using map function of Stream
Just because you can do it in streams, that doesn't mean you should. What you really want is the following:

public static List&lt;String&gt; deleteDeliveryTemplates(String... deliveryTemplateNames) {
    List&lt;String&gt; failures = new ArrayList&lt;&gt;();
    for (String templateName : deliveryTemplateNames) {
        try {
            deleteDeliveryTemplate(templateName);
        } catch (Exception e) {
            // LOG THIS EXCEPTION!
            failures.add(templateName);
        }
    }
    return failures;
}


This code is clean, simple, does one thing. Note that I removed the overspecification of generics on the right-hand-side of the failureList declaration and changed the names of your local variables a bit to make use of the surrounding context.

I also slightly reformatted the brace positions in try-blocks to be more in line with the usual Java conventions. As long as you're consistent, there's nothing wrong with your style though.