Determining the largest sum of contiguous integers in a list I'm curious how I can improve the readability of this short program I wrote. Mainly, if and how there is a way to remove the for loops and maybe refactor the getTruncatedSubListsOf methods to one method since they are pretty similar. I tried using comments only when clarification was necessary.

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;

import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;


/**
 *  A program to determine the largest sum of contiguous integers in a list.
 *  The first argument is a path to a filename containing a comma-separated list of integers, one per line.
 *  The largest sum is printed to stdout. In other words, of all the possible contiguous subarrays for a given array,
 *  the one with the largest sum is found and printed.
 */
public class SumOfIntegers {

    public static void main(String[] args) throws IOException {

        Files.newBufferedReader(Paths.get(args[0])).lines()
                                                    .map(SumOfIntegers::turnToIntegerList)
                                                    .map(SumOfIntegers::getAllContiguousSubarrays)
                                                    .map(SumOfIntegers::getSumsOfSubarrays)
                                                    .mapToInt(Collections::max)
                                                    .forEach(System.out::println);
    }

    private static List&lt;Integer&gt; turnToIntegerList(String line) {

        return asList(line.split(",")).stream()
                                      .map(Integer::valueOf)
                                      .collect(toList());
    }

    /**
     * Returns all possible contiguous subarrays for a given List. This method calls getEndTruncatedSubListsOf each
     * different frontTruncatedSubList, yielding all possible front and end truncated lists - which are all subarrays.
     * @param integerList A List containing Integer values.
     * @return A List of all subarrays as Lists.
     */
    private static List&lt;List&lt;Integer&gt;&gt; getAllContiguousSubarrays(List&lt;Integer&gt; integerList) {
        List&lt;List&lt;Integer&gt;&gt; result = new ArrayList&lt;&gt;();

        for (List&lt;Integer&gt; frontTruncatedSubList : getFrontTruncatedSubListsOf(integerList)) {
            result.addAll(getEndTruncatedSubListsOf(frontTruncatedSubList));
        }

        return result;
    }

    private static List&lt;List&lt;Integer&gt;&gt; getFrontTruncatedSubListsOf(List&lt;Integer&gt; list) {
        List&lt;List&lt;Integer&gt;&gt; result = new ArrayList&lt;&gt;();

        for (int i = 0; i &lt; list.size(); i++) {
            result.add(list.subList(i, list.size()));
        }

        return result;
    }

    private static List&lt;List&lt;Integer&gt;&gt; getEndTruncatedSubListsOf(List&lt;Integer&gt; list) {
        List&lt;List&lt;Integer&gt;&gt; result = new ArrayList&lt;&gt;();

        for (int i = 0; i &lt; list.size(); i++) {
            result.add(list.subList(0, list.size() - i));
        }

        return result;
    }

    private static List&lt;Integer&gt; getSumsOfSubarrays(List&lt;List&lt;Integer&gt;&gt; subarrays) {
        return subarrays.stream()
                .map(subsubarray -&gt; subsubarray.stream()
                                                .mapToInt(integer -&gt; integer)
                                                .sum())
                .collect(toList());
    }



}
Unit testing

As it currently stands, testing your class means having to feed it a filesystem-based input (even if it's using something in-memory like Jimfs). You should consider implementing your application logic such that the input is the form of Stream&lt;String&gt;, so that the source of that stream is independent of the processing here.

String splitting as Stream&lt;String&gt;

Array.asList(string.split(",")).stream()


This can be better represented using Pattern.splitAsStream(CharSequence)

// consider making Pattern.compile(",") a static Pattern field too
Pattern.compile(",").splitAsStream(string)