-1
I have this code in C#. A lambda expression that searches for files in a directory using regex and plays those files in a function by running a command line. All found files are added in "Task" to run in parallel. How would the corresponding of this expression in Java?
_ = await Task.Run(() =>
{
return Parallel.ForEach(GameFiles.Where(f => Regex.IsMatch(f, pattern: FileLocationInfo.DlgPattern)), item => tw.GetFile($"-e -t", item));
});
Edit: "Gamefiles" contains the folder with several files from a game. "Regex" is used to select only the files I want. It has files with the same extension that I don’t care about. "tw.Getfile" is a method with the command-line app.
"Regex" selects the files in "Gamefiles", that are played one by one in the method "tw.Getfiles" and then executed in parallel.
The app is a few KB and the files have 4MB at most. It is more convenient to run in parallel.
does not seem to me to be a question of the lambda... but rather the appeal of the
Paralell.ForEach
. Present the code of how you are trying to play this chunk of code in Java.– Leandro Angelo
In relation to
Paralell.ForEach
you can throughStream::parallelStream
.– chriptus13