In the program that I am writing now, I find that I am doing the following a lot ...
Map<String,List<String>> network = loadSerializedObj(file); // null if failed if(network != null) { anonNet = util.anonymize(newNet); } else { // Some sort of error handling. System.out.println("Some sort of error message. Exiting..."); System.exit(0); }
Is there a shorter way to handle the event when loading a serialized object from a file does not work and the method returns null? Any advice is generally welcome. Anywhere I can make it more elegant?
source share