Skip to content

Instantly share code, notes, and snippets.

//Null pointer exception risk
item.getOne().getTwo().whereIsTheData();
//or ugly
One one = item.getOne();
if (one != null) {
Two two = one.getTwo();
if (two != null) {
Data data = two.whereIsTheData();
@LuizGC
LuizGC / DownloadInputStream.java
Created February 5, 2020 15:27
Java code to download and unzip files in memory
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.zip.ZipInputStream;
public class Main {
public static void main(String... args) throws Exception {
URL url = new URL(args[0]);
URLConnection con = url.openConnection();
ZipInputStream zipStream = new ZipInputStream(con.getInputStream());