Monthly Archives: October 2021

Unexpected NullPointerException (NPE) in ternary conditional operator in Java

Sometimes I come across Java code that unexpectedly throws NullPointerException in ternary operator. It is especially surprising if this particular line of code seems very simple like: or even: At first, it might look like the condition is not met … Continue reading

Posted in Java, Uncategorized | Tagged | Leave a comment

Create text file in Java with contents

Creating a text file (with given contents) is pretty straightforward task in Java. Recent Java versions and popular libraries like Apache Commons or Guava make this task even easier than it used to be. Below are some ways how to … Continue reading

Posted in Guava, Java | Tagged | Leave a comment