Small net update

This commit is contained in:
topjohnwu 2019-04-03 01:01:18 -04:00
parent 036b5acf42
commit 0c7a95bdf6

View File

@ -15,10 +15,9 @@ import java.io.FileOutputStream;
import java.io.FilterInputStream; import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Reader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.util.Scanner;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
public class Request implements Closeable { public class Request implements Closeable {
@ -192,15 +191,10 @@ public class Request implements Closeable {
} }
private String dlString() throws IOException { private String dlString() throws IOException {
StringBuilder builder = new StringBuilder(); try (Scanner s = new Scanner(getInputStream(), "UTF-8")) {
try (Reader reader = new InputStreamReader(getInputStream())) { s.useDelimiter("\\A");
int len; return s.next();
char[] buf = new char[4096];
while ((len = reader.read(buf)) != -1) {
builder.append(buf, 0, len);
}
} }
return builder.toString();
} }
private JSONObject dlJSONObject() throws IOException, JSONException { private JSONObject dlJSONObject() throws IOException, JSONException {