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

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值