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.
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.
本文介绍了如何从Amazon S3中读取文件流,并通过BufferedReader进行逐行处理的方法。同时探讨了InputStream.available()方法在不同场景下的行为,特别是在SSL套接字上的表现。
218

被折叠的 条评论
为什么被折叠?



