使用Java时,进程输入流是否有限制? [英] Is there a limit on process input stream when using java?

查看:92
本文介绍了使用Java时,进程输入流是否有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在solaris操作系统上使用Java运行时创建进程.然后,我从流程中获取输入流,并对输入流进行读取.我期望(我不太确定此过程,这是第三者的事情)该过程的外部流很大,但似乎受到了限制.难道在Java端是否有一个阈值可以确定一个进程在其输出流中可以有多少个?

I am creating a process using java runtime on a solaris OS. I then get inputstream from the process and do a read on the input stream. I expect (I am not too sure about the process, it is a 3rd party thing)the process outstream to be huge but it seems to be clipped. Could it be that there is a threshold on java side as to how much a process can have in its output stream?

谢谢, 阿卜杜勒

推荐答案

如果反复读取,则可以读取的数据量没有限制.您一次读取的容量不能超过2 GB,某些流类型一次只能提供几个KB.例如缓慢的Socket通常会给您1.5 KB或更少的内存(基于连接的MTU)

There is no limit to the amount of data you can read, if you read repeatedly. You cannot read more than 2 GB at once and some stream types might only give you a few KB at a time. e.g. a slow Socket will often given you 1.5 KB or less (based on the MTU of the connection)

如果调用int read(byte[]),则只能保证读取1个字节.假设您每次都会读取完整的缓冲区是一个常见的错误.如果需要,可以使用DataInputStream.readFully(byte[])

If you call int read(byte[]) it is only guaranteed to read 1 byte. It is a common mistake to assume you will read the full buffer every time. If you need this you can use DataInputStream.readFully(byte[])

这篇关于使用Java时,进程输入流是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆