Skip to content

Tag: java-8

Java ProcessBuilder: How to suppress output instead of redirecting it

I’m using a ProcessBuilder to execute commands and redirect the output. I now want to add the possibility to have no output at all. Of course I could redirect into a file, but this would leave unnecessary files on the users system. I am looking for a solution that works on all platforms, including Windows (e.g. not redirecting to /dev/null)

How to implement the Elvis operator in Java 8?

I have the classic “Elvis operator” case, where I’m calling methods that each may return null and chaining them together: In Java 8, the most faithful implementation I’ve found is something like this: I wish that Java’s Optional had something akin to the elvis operator: So that I wouldn’t have to wrap each return value: Is there a more efficient

What is the difference between intermediate and terminal operations?

can someone tell me What is the difference between intermediate and terminal operations for Stream? Stream operations are combined into pipelines to process streams. All operations are either intermediate or terminal ..means?. Answer A Stream supports several operations and these operations are divided into intermediate and terminal operations. The distinction between this operations is that an intermediate operation is lazy