13.3.6.23 Read(char[ ], int, int)
このインスタンス・メソッドでは、現行のインスタンスから指定バイト数を読み取り、文字配列バッファに移入します。
宣言
// C# public int Read(char[ ] buffer, int offset, int count);
パラメータ
-
buffer
移入される文字配列バッファ
-
offset
バッファに移入されるオフセット(文字)
-
count
読み取られる文字数
戻り値
戻り値はCLOB
から読み取られる文字数を示します。
例外
ObjectDisposedException
- オブジェクトはすでに処理されています。
InvalidOperationException
- OracleConnection
がオープンされていないか、またはオブジェクトの存続中にクローズされています。
ArgumentOutOfRangeException
- この例外は次のいずれかの条件が存在する場合に表示されます。
-
offset
またはcount
が0
未満の場合 -
offset
がbuffer
.Length
以上である場合 -
offset
およびcount
の合計がbuffer
.Length
より大きい場合
備考
すべてのCLOB
およびNCLOB
データをUnicodeとして処理します。
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(); OracleClob clob = new OracleClob(con); // Write 3 chars, starting at buffer offset 1 char[] writeBuffer = new char[4] {'a', 'b', 'c', 'd'}; clob.Write(writeBuffer, 1, 3); // Reset the Position (in bytes) for Read clob.Position = 2; // Read 2 chars into buffer starting at buffer offset 1 char[] readBuffer = new char[4]; int charsRead = clob.Read(readBuffer, 1, 2); // Prints "charsRead = 2" Console.WriteLine("charsRead = " + charsRead); // Prints "readBuffer = cd " Console.Write("readBuffer = "); for(int index = 0; index < readBuffer.Length; index++) { Console.Write(readBuffer[index]); } Console.WriteLine(); clob.Close(); clob.Dispose(); con.Close(); con.Dispose(); } }