Read
Stream
をオーバーライドします
このインスタンス・メソッドでは、ODP.NET LOBインスタンスから指定バイト数を読み取り、buffer
に移入します。
宣言
// C# public override int Read(byte[] buffer, int offset, int count);
パラメータ
-
buffer
移入されるバイト配列バッファ
-
offset
バッファに移入される開始オフセット(バイト)
-
count
読取りバイト数
戻り値
戻り値はLOBから読み取られるバイト数を示します。
例外
ObjectDisposedException
- オブジェクトはすでに処理されています。
InvalidOperationException
- OracleConnection
がオープンされていないか、またはオブジェクトの存続中にクローズされています。
ArgumentOutOfRangeException
- この例外は次のいずれかの条件が存在する場合に表示されます。
-
offset
またはcount
パラメータが0
未満の場合 -
offset
がbuffer
.Length
以上である場合 -
offset
およびcount
の合計がbuffer
.Length
より大きい場合
備考
LOBデータの読取りは、Position
プロパティにより指定された位置から開始されます。
例
// C# using System; using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; class ReadSample { static void Main() { string constr = "User Id=scott;Password=tiger;Data Source=oracle"; OracleConnection con = new OracleConnection(constr); con.Open(); OracleBlob blob = new OracleBlob(con); // Write 3 bytes, starting at buffer offset 1 byte[] writeBuffer = new byte[4] {1, 2, 3, 4}; blob.Write(writeBuffer, 1, 3); // Reset the Position for Read blob.Position = 1; // Read 2 bytes into buffer starting at buffer offset 1 byte[] readBuffer = new byte[4]; int bytesRead = blob.Read(readBuffer, 1, 2); // Prints "bytesRead = 2" Console.WriteLine("bytesRead = " + bytesRead); // Prints "readBuffer = 0340" Console.Write("readBuffer = "); for(int index = 0; index < readBuffer.Length; index++) { Console.Write(readBuffer[index]); } Console.WriteLine(); blob.Close(); blob.Dispose(); con.Close(); con.Dispose(); } }