({{, (RefLink[RemoveOutputStreamMethod, paclet:ref/RemoveOutputStreamMethod])["name"] 
removes a custom output stream method.}})

OpenersNotesSection(Spacer1)Details

"name" should be the name passed to (RefLink[DefineOutputStreamMethod, paclet:ref/DefineOutputStreamMethod]) when the stream method was defined.

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Define a stream method that keeps a checksum of the file contents:

ChecksumOutputStreamConstructor[name_,___]:=
{"stream"->OpenWrite[name,BinaryFormat->True],"sum"->0}

ChecksumOutputStreamWrite[{"stream"->st_OutputStream,"sum"->previous_},bytes_List]:=
With[{result=BinaryWrite[st,bytes]},
{Length[bytes],{"stream"->st,"sum"->previous+Total[bytes]}}
]

DefineOutputStreamMethod["ChecksumFile",
{"ConstructorFunction"->ChecksumOutputStreamConstructor,
"CloseFunction"->(Close["stream"/.#]&),
"WriteFunction"->ChecksumOutputStreamWrite,
"OptionChangesFunction"->(
{{{},{"Checksum"->("sum"/.#)}},#}&)
}]

The new output stream method is listed:

$OutputStreamMethods

Remove it:

RemoveOutputStreamMethod["ChecksumFile"]

This output stream method is no longer defined:

$OutputStreamMethods

Confirm that a stream cannot be opened with this stream method now:

OpenWrite[FileNameJoin[{$UserBaseDirectory,"example.txt"}],Method->"ChecksumFile"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DefineOutputStreamMethod, paclet:ref/DefineOutputStreamMethod])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Stream Methods, paclet:tutorial/StreamMethods])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Stream Methods, paclet:guide/StreamMethods])}})}})