`
神不为者人为之
  • 浏览: 7822 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

 
阅读更多
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.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics