BufferedStream.Write 메서드

정의

오버로드

Write(ReadOnlySpan<Byte>)

현재 버퍼링된 스트림에 바이트 시퀀스를 쓰고 쓴 바이트 수만큼 이 버퍼링된 스트림에서 현재 위치를 앞으로 이동합니다.

Write(Byte[], Int32, Int32)

버퍼링된 스트림에 바이트를 복사하고 버퍼링된 스트림 내에서의 현재 위치를 쓴 바이트 수만큼 이동합니다.

Write(ReadOnlySpan<Byte>)

현재 버퍼링된 스트림에 바이트 시퀀스를 쓰고 쓴 바이트 수만큼 이 버퍼링된 스트림에서 현재 위치를 앞으로 이동합니다.

public:
 override void Write(ReadOnlySpan<System::Byte> buffer);
public override void Write (ReadOnlySpan<byte> buffer);
override this.Write : ReadOnlySpan<byte> -> unit
Public Overrides Sub Write (buffer As ReadOnlySpan(Of Byte))

매개 변수

buffer
ReadOnlySpan<Byte>

메모리 영역입니다. 이 메서드는 이 영역의 내용을 현재의 버퍼링된 스트림에 복사합니다.

설명

CanWrite 이 속성을 사용하여 현재 인스턴스가 쓰기를 지원하는지 여부를 확인합니다. 메서드를 WriteAsync 사용하여 현재 버퍼링된 스트림에 비동기적으로 작성합니다.

쓰기 작업이 성공하면 버퍼링된 스트림 내의 위치가 기록된 바이트 수만큼 진행됩니다. 예외가 발생하면 버퍼링된 스트림 내의 위치는 변경되지 않습니다.

적용 대상

Write(Byte[], Int32, Int32)

버퍼링된 스트림에 바이트를 복사하고 버퍼링된 스트림 내에서의 현재 위치를 쓴 바이트 수만큼 이동합니다.

public:
 override void Write(cli::array <System::Byte> ^ array, int offset, int count);
public:
 override void Write(cli::array <System::Byte> ^ buffer, int offset, int count);
public override void Write (byte[] array, int offset, int count);
public override void Write (byte[] buffer, int offset, int count);
override this.Write : byte[] * int * int -> unit
override this.Write : byte[] * int * int -> unit
Public Overrides Sub Write (array As Byte(), offset As Integer, count As Integer)
Public Overrides Sub Write (buffer As Byte(), offset As Integer, count As Integer)

매개 변수

arraybuffer
Byte[]

count 바이트를 현재 버퍼링된 스트림에 복사할 바이트 배열입니다.

offset
Int32

버퍼링된 현재 스트림으로 바이트를 복사하기 시작할 버퍼의 오프셋입니다.

count
Int32

현재 버퍼링된 스트림에 쓸 바이트 수입니다.

예외

array 길이에서 offset을 뺀 값이 count보다 작은 경우

array이(가) null인 경우

offset 또는 count가 음수입니다.

스트림이 닫혀 있거나 null인 경우

스트림이 쓰기를 지원하지 않습니다.

스트림이 닫힌 후에 메서드가 호출되었습니다.

예제

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 BufferedStream 클래스입니다.

// Send the data using the BufferedStream.
Console::WriteLine( "Sending data using BufferedStream." );
startTime = DateTime::Now;
for ( int i = 0; i < numberOfLoops; i++ )
{
   bufStream->Write( dataToSend, 0, dataToSend->Length );

}
bufStream->Flush();
bufferedTime = (DateTime::Now - startTime).TotalSeconds;
Console::WriteLine( "{0} bytes sent in {1} seconds.\n", (numberOfLoops * dataToSend->Length).ToString(), bufferedTime.ToString(  "F1" ) );
// Send the data using the BufferedStream.
Console.WriteLine("Sending data using BufferedStream.");
startTime = DateTime.Now;
for(int i = 0; i < numberOfLoops; i++)
{
    bufStream.Write(dataToSend, 0, dataToSend.Length);
}
bufStream.Flush();
bufferedTime = (DateTime.Now - startTime).TotalSeconds;
Console.WriteLine("{0} bytes sent in {1} seconds.\n",
    numberOfLoops * dataToSend.Length,
    bufferedTime.ToString("F1"));
// Send the data using the BufferedStream.
printfn "Sending data using BufferedStream."
let startTime = DateTime.Now
for _ = 0 to numberOfLoops - 1 do
    bufStream.Write(dataToSend, 0, dataToSend.Length)
bufStream.Flush()
let bufferedTime = (DateTime.Now - startTime).TotalSeconds
printfn $"{numberOfLoops * dataToSend.Length} bytes sent in {bufferedTime:F1} seconds.\n"
' Send the data using the BufferedStream.
Console.WriteLine("Sending data using BufferedStream.")
startTime = DateTime.Now
For i As Integer = 1 To numberOfLoops
    bufStream.Write(dataToSend, 0, dataToSend.Length)
Next i

bufStream.Flush()
bufferedTime = DateTime.Now.Subtract(startTime).TotalSeconds
Console.WriteLine("{0} bytes sent In {1} seconds." & vbCrLf, _
    numberOfLoops * dataToSend.Length, _
    bufferedTime.ToString("F1"))

추가 정보

적용 대상