Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39886

Re: Is it possible to send message bursts?

Path csiph.com!aioe.org!LeVffQP25j5GAigzc2gaQA.user.46.165.242.75.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Is it possible to send message bursts?
Date Mon, 2 Jan 2023 10:42:35 -0500
Organization Aioe.org NNTP Server
Message-ID <touu1b$9tp$1@gioia.aioe.org> (permalink)
References <7128506e-015c-4992-8ee4-9c62fb2ccc11n@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Info gioia.aioe.org; logging-data="10169"; posting-host="LeVffQP25j5GAigzc2gaQA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1
Content-Language en-US
X-Notice Filtered by postfilter v. 0.9.2
Xref csiph.com comp.lang.java.programmer:39886

Show key headers only | View raw


On 1/2/2023 5:10 AM, mike wrote:
> I am reading data from an inputstream. To test the function
> I use a String that I convert to a byte array and the to a Stream.
> using the following:
>   return new ByteArrayInputStream(message.getBytes());
> 
> I am reading in a loop like this:
> 
> int character = 1;
> 		try (BufferedInputStream bis = new BufferedInputStream(inputStream)) {
> 			while (running) {
> 				if (!suspended)
> 					character = bis.read();
> 
> 
> Problem is when I test this is that I want to send message that first
> has some data and then no data giving making read() return -1 and
> then data again. Is it possible to create an inputstream that
> supports this behaviour?
I don't understand. read() is a blocking method, so if there
is no input it blocks until there is input. It returns -1
if end of stream is reached (and stream is then invalid and
no point in calling read again).

You can easily write am InputStream class that pause a bit before
returning from read(), but does that really make sense?

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is it possible to send message bursts? mike <mikaelpetterson@hotmail.com> - 2023-01-02 02:10 -0800
  Re: Is it possible to send message bursts? Arne Vajhøj <arne@vajhoej.dk> - 2023-01-02 10:42 -0500
    Re: Is it possible to send message bursts? Andreas Leitgeb <avl@logic.at> - 2023-01-02 19:05 +0000
      Re: Is it possible to send message bursts? Andreas Leitgeb <avl@logic.at> - 2023-01-02 19:13 +0000
      Re: Is it possible to send message bursts? Arne Vajhøj <arne@vajhoej.dk> - 2023-01-02 19:27 -0500
  Re: Is it possible to send message bursts? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-01-03 04:07 -0800

csiph-web