all groups > vj# > april 2004 >
You're in the

vj#

group:

Invoking the J# available() function from C#


Invoking the J# available() function from C# Mazen
4/26/2004 9:31:03 AM
vj#: I am trying to find an equivalent C# built-in function that does the same as the J# method available() which can be invoked on a BufferedInputStream object. The available() method is useful to detect the number of bytes available to a stream reader (such as in the case of a client/server socket connection)

Re: Invoking the J# available() function from C# Lars-Inge Tønnessen
4/27/2004 4:59:15 PM

A C# file example. Let's say you have a file called "test.txt".


static void Main(string[] args)
{
System.IO.FileStream file = new System.IO.FileStream("test.txt",
System.IO.FileMode.Open, System.IO.FileAccess.Read);

System.Console.WriteLine("Stream lenth: "+file.Length );
file.Close();
}

".Length" gets the length of a stream in bytes.


Regards,
Lars-Inge Tønnessen
www.larsinge.com

AddThis Social Bookmark Button