我目前使用以下函数来执行简单的HTTP GET.
public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); try { s = (java.io.InputStream)new URL(url).getContent(); r = new java.io.InputStreamReader(s); //b = new java.io.BufferedReader(r); char[] buffer = new char[4*1024]; int n = 0; while (n >= 0) { n = r.read(buffer, 0, buffer.length); if (n > 0) { content.append(buffer, 0, n); } } } finally { //if (b != null) b.close(); if (r != null) r.close(); if (s != null) s.close(); } return content.toString(); }
我认为没有理由使用,BufferedReader
因为我只是按顺序下载所有内容.我是否认为BufferedReader
在这种情况下没有用处?