package mmk; import java.io.IOException; import java.net.URL; import java.util.Scanner; public class JsonConn { public static void main(String[] args) throws IOException { URL url = new URL("https://random-word-api.herokuapp.com/word?number=10"); String inline = ""; Scanner scanner = new Scanner(url.openStream()); //Write all the JSON data into a string using a scanner while (scanner.hasNext()) { inline += scanner.nextLine(); } scanner.close(); System.out.println(inline); } }