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();
}
}