互换的青春
PI请求:Java 与 Kotlin对比 我总喜欢把这两种语言进行对比,看看坚持使用Java我们会错过什么。从URL恢复JSON的典型代码是这样:1 try { 2 URL url = new URL("<api call>"); 3 4 urlConnection = (HttpURLConnection) url.openConnection(); 5 urlConnection.setRequestMethod("GET"); 6 urlConnection.connect(); 7 8 InputStream inputStream = urlConnection.getInputStream(); 9 StringBuffer buffer = new StringBuffer();