@@ -0,0 +1,1344 @@
+package study.hard.javalib.encodingstring;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.net.URL;%0Aimport java.nio.charset.StandardCharsets;%0A%0Aimport org.apache.commons.lang.StringUtils;%0Aimport org.junit.Test;%0A%0Apublic class InputStreamTest %7B%0A%0A%09@Test%0A%09public void testBytesRead() throws IOException %7B%0A%09%09URL url = new URL(%22http://www.google.com%22);%0A%09%09StringBuilder stringBuilder = new StringBuilder();%0A%09%09BufferedReader bufferedReader = null;%0A%0A%09%09try %7B%0A%09%09%09InputStream inputStream = url.openStream();%0A%09%09%09if (inputStream != null) %7B%0A%09%09%09%09bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));%0A%09%09%09%09char%5B%5D charBuffer = new char%5B1024%5D;%0A%09%09%09%09int bytesRead = -1;%0A%09%09%09%09while ((bytesRead = bufferedReader.read(charBuffer)) %3E 0) %7B%0A%09%09%09%09%09stringBuilder.append(charBuffer, 0, bytesRead);%0A%09%09%09%09%7D%0A%09%09%09%7D else %7B%0A%09%09%09%09stringBuilder.append(%22%22);%0A%09%09%09%7D%0A%09%09%7D catch (IOException ex) %7B%0A%09%09%09throw ex;%0A%09%09%7D finally %7B%0A%09%09%09if (bufferedReader != null) %7B%0A%09%09%09%09try %7B%0A%09%09%09%09%09bufferedReader.close();%0A%09%09%09%09%7D catch (IOException ex) %7B%0A%09%09%09%09%09throw ex;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09assertTrue(StringUtils.isNotBlank(stringBuilder.toString()));%0A%09%09System.out.println(%22%3E %22 + stringBuilder);%0A%09%09System.out.println(%22length: %22 + stringBuilder.length());%0A%09%7D%0A%0A%7D%0A

Add some codes to test InputStream.