Java to .Net conversion - problem with InputStream

  • Thread starter Thread starter DM
  • Start date Start date
D

DM

Hello.

Originally I post this message to microsoft.public.dotnet.general,
but I was advised thath this group is more suitable so I resent it here:

I'm trying to port Java application to C#. During
my effort I enoucntered a problem for which I can't find
an easy solution.
Ad rem: The program I'm trying to port uses available()
method of Java's InputStream. This method returns numer of bytes
available for reading without blocking the procces. Unfortunately
System.IO.Stream does not provide similar functionality. Does
anyone know any solution, workaround for this problem??

Thank you.
 
DM said:
Originally I post this message to microsoft.public.dotnet.general,
but I was advised thath this group is more suitable so I resent it here:

I'm trying to port Java application to C#. During
my effort I enoucntered a problem for which I can't find
an easy solution.
Ad rem: The program I'm trying to port uses available()
method of Java's InputStream. This method returns numer of bytes
available for reading without blocking the procces. Unfortunately
System.IO.Stream does not provide similar functionality. Does
anyone know any solution, workaround for this problem??

I'd avoid using any equivalent anyway, to be honest - available()
should almost always be avoided in Java too, IME. It's unreliable and
causes problems.

Do you particularly need to read without blocking? If so, would reading
asynchronously be good enough? If so, look at Stream.BeginRead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top