Read
Streamをオーバーライドします
このインスタンス・メソッドでは、OracleBFileインスタンスから指定バイト数を読み取り、bufferを移入します。
宣言
// C# public override int Read(byte[] buffer, int offset, int count);
パラメータ
-
buffer移入されるバイト配列バッファ
-
offset移入されるバイト配列バッファのオフセット
-
count読取りバイト数
戻り値
この戻り値は、BFILE、つまり外部LOBから読み取られるバイト数を示します。
例外
ObjectDisposedException - オブジェクトはすでに処理されています。
InvalidOperationException - OracleConnectionがオープンされていないか、またはオブジェクトの存続中にクローズされています。
ArgumentOutOfRangeException - offsetまたはcountパラメータが0未満、offsetがbuffer.Length以上、またはoffsetとcountの合計がbuffer.Lengthより大きい場合のいずれか。
備考
LOBデータの読取りは、Positionプロパティにより指定された位置から開始されます。
例
// Database Setup, if you have not done so yet.
/* Log on as DBA (SYS or SYSTEM) that has CREATE ANY DIRECTORY privilege.
CREATE OR REPLACE DIRECTORY MYDIR AS 'C:\TEMP';
*/
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class ReadSample
{
static void Main()
{
// Create MYDIR directory object as indicated previously and create a file
// MyFile.txt with the text ABCDABC under C:\TEMP directory.
// Note that the byte representation of the ABCDABC is 65666768656667
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleBFile bFile = new OracleBFile(con, "MYDIR", "MyFile.txt");
// Open the OracleBFile
bFile.OpenFile();
// Read 7 bytes into readBuffer, starting at buffer offset 0
byte[] readBuffer = new byte[7];
int bytesRead = bFile.Read(readBuffer, 0, 7);
// Prints "bytesRead = 7"
Console.WriteLine("bytesRead = " + bytesRead);
// Prints "readBuffer = 65666768656667"
Console.Write("readBuffer = ");
for(int index = 0; index < readBuffer.Length; index++)
{
Console.Write(readBuffer[index]);
}
Console.WriteLine();
// Close the OracleBFile
bFile.CloseFile();
bFile.Close();
bFile.Dispose();
con.Close();
con.Dispose();
}
}