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