【发布时间】:2010-11-13 05:59:24
【问题描述】:
我在 Windows 机器中使用 gzip 实用程序。我压缩了一个文件并作为 blob 存储在数据库中。当我想使用 gzip 实用程序解压缩此文件时,我正在将此字节流写入 process.getOutputStream。但是在 30KB 之后,它无法读取文件。它挂在那里。
尝试了内存参数、读取和刷新逻辑。但是如果我尝试写入文件,同样的数据会非常快。
OutputStream stdin = proc.getOutputStream();
Blob blob = Hibernate.createBlob(inputFileReader);
InputStream source = blob.getBinaryStream();
byte[] buffer = new byte[256];
long readBufferCount = 0;
while (source.read(buffer) > 0)
{
stdin.write(buffer);
stdin.flush();
log.info("Reading the file - Read bytes: " + readBufferCount);
readBufferCount = readBufferCount + 256;
}
stdin.flush();
问候, Mani Kumar Adari。
【问题讨论】:
标签: java runtime io stream outputstream