BinaryReader.Close メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BinaryReader.Close メソッドの意味・解説 

BinaryReader.Close メソッド

現在のリーダーと基になるストリームクローズます。

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説

この Close実装は、true 値を渡す Dispose メソッド呼び出します。

ストリームフラッシュしても、Flush または Close明示的に呼び出さない限り、そのストリームの基になるエンコーダフラッシュされません。AutoFlush を true設定すると、データバッファからストリームフラッシュされますが、エンコーダの状態はフラッシュされません。これにより、エンコーダの状態 (一部文字) を維持できるため、次のブロック文字正確にエンコードできるようになります。この動作は、一部文字エンコードするためにはエンコーダがあらかじめその文字隣接する文字受け取っておく必要がある UTF8 および UTF7 に対して有効です。

使用例使用例

このコード例は、BinaryReader クラストピック取り上げているコード例一部分です。

Dim binReader As New BinaryReader(
 _
    File.Open(fileName, FileMode.Open))
Try

    ' If the file is not empty, 
    ' read the application settings.
    If binReader.PeekChar() <> -1 Then
        aspRatio   = binReader.ReadSingle()
        lkupDir     = binReader.ReadString()
        saveTime  = binReader.ReadInt32()
        statusBar = binReader.ReadBoolean()
        Return
    End If

' If the end of the stream is reached before reading
' the four data values, ignore the error and use the
' default settings for the remaining values.
Catch ex As EndOfStreamException
    Console.WriteLine("{0} caught and ignored. " &
 _ 
        "Using default values.", ex.GetType().Name)
Finally
    binReader.Close()
End Try
BinaryReader binReader = 
    new BinaryReader(File.Open(fileName, FileMode.Open));
try
{
    // If the file is not empty, 
    // read the application settings.
    if(binReader.PeekChar() != -1)
    {
        aspectRatio   = binReader.ReadSingle();
        lookupDir     = binReader.ReadString();
        autoSaveTime  = binReader.ReadInt32();
        showStatusBar = binReader.ReadBoolean();
    }
}

// If the end of the stream is reached before reading
// the four data values, ignore the error and use the
// default settings for the remaining values.
catch(EndOfStreamException e)
{
    Console.WriteLine("{0} caught and ignored. " + 
        "Using default values.", e.GetType().Name);
}
finally
{
    binReader.Close();
}
BinaryReader^ binReader = gcnew BinaryReader( File::Open( fileName, FileMode::Open
 ) );
try
{
   
   // If the file is not empty, 
   // read the application settings.
   if ( binReader->PeekChar() != -1 )
   {
      aspectRatio = binReader->ReadSingle();
      lookupDir = binReader->ReadString();
      autoSaveTime = binReader->ReadInt32();
      showStatusBar = binReader->ReadBoolean();
      return;
   }
}
// If the end of the stream is reached before reading
// the four data values, ignore the error and use the
// default settings for the remaining values.
catch ( EndOfStreamException^ e ) 
{
   Console::WriteLine( "{0} caught and ignored. "
   "Using default values.", e->GetType()->Name
 );
}
finally
{
   binReader->Close();
}


BinaryReader binReader =
    new BinaryReader(File.Open(fileName, FileMode.Open));
try {
    // If the file is not empty, 
    // read the application settings.
    if ( binReader.PeekChar() !=-1  ) {
        aspectRatio = binReader.ReadSingle();
        lookupDir = binReader.ReadString();
        autoSaveTime = binReader.ReadInt32();
        showStatusBar = binReader.ReadBoolean();
    }
}

// If the end of the stream is reached before reading
// the four data values, ignore the error and use the
// default settings for the remaining values.
catch(EndOfStreamException e) {
    Console.WriteLine("{0} caught and ignored. "
        + "Using default values.", e.GetType().get_Name());
}
finally {
    binReader.Close();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からBinaryReader.Close メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBinaryReader.Close メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBinaryReader.Close メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

BinaryReader.Close メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BinaryReader.Close メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS