java.net.HttpURLConnection httpURLConnection = (java.net.HttpURLConnection) url.openConnection(); httpURLConnection.setDoInput(true); httpURLConnection.setRequestMethod("GET"); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpURLConnection.connect(); InputStream inputStream = httpURLConnection.getInputStream(); byte[] byteArray = new byte[1024]; int len = 0; int ascii = inputStream.read(); byteArray[len] = (byte) ascii; while (ascii > -1) { ascii = inputStream.read(); len ++; byteArray[len] = (byte) ascii; } result = new String(byteArray, 0, len);
java从输入流读取ASCII
最新推荐文章于 2024-09-12 21:04:39 发布