I would like to know how to shorten my code with the help of Stream Api. Let's say I have method like this:
public static void createFile( String directoryPath, String fileName )
And I would like to call this method 5 times with the same parameters. For example
for (int i = 0; i < 5; i++) {
Utils.createFile(getDirectoryLocation(), "test.txt");
}
I know I can do something like this:
IntStream.rangeClosed(1, 5).forEach(Utils::someMethod);
But here I am passing one integer value to method. Anyone can give me some hints or answers?