ITeye博客

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

神不为者人为之 · 2014-08-20 13:40 · 移动开发 · Markdown

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.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。