得抽空看一下底层实现了..

InputStream stream = getLogFileFromS3(filePath);
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(stream));
while (bufferedReader.ready()) {
   String line = bufferedReader.readLine();
}

BufferedInputStream.available() tells you how many bytes can be read without blocking. This is the sum of the number of bytes already in the buffer and the avaiable() result of the nested input stream. Note also that available() always returns zero for an SSL socket.

InputStream.available() on an SSL socket always returns zero because it can't tell how much data is available to read without blocking unless it decrypts some data, and it can't in general do that without blocking because SSL comes in discrete records. So it returns zero. So you have to dedicate a thread to reading the socket and blocking while it does so.

猜你喜欢

转载自log4i.iteye.com/blog/2106354