Wolfram Research

Function Repository Resource:

OpenStreamQ

Source Notebook

Test if a stream is open

Contributed by: Taliesin Beynon

ResourceFunction["OpenStreamQ"][stream]

returns True if stream is opened and False otherwise.

Examples

Basic Examples

Test if a stream is open:

In[1]:=
str = StringToStream["abc efg hij"]
Out[1]=
In[2]:=
ResourceFunction["OpenStreamQ"][str]
Out[2]=
In[3]:=
Close[str]
Out[3]=
In[4]:=
ResourceFunction["OpenStreamQ"][str]
Out[4]=

Open another stream:

In[5]:=
stmp = OpenWrite["tmp"]
Out[5]=
In[6]:=
ResourceFunction["OpenStreamQ"][stmp]
Out[6]=
In[7]:=
Close[stmp]
Out[7]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information