BinaryReader コンストラクタとは? わかりやすく解説

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

BinaryReader コンストラクタ (Stream)

指定したストリームを基にし、UTF8Encoding を使用して、BinaryReader クラス新しインスタンス初期化します。

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

例外例外
例外種類条件

ArgumentException

ストリーム読み取りサポートしていないか、null 参照 (Visual Basic では Nothing) であるか、または既に閉じてます。

解説解説
使用例使用例

このコード例は、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();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

BinaryReader コンストラクタ (Stream, Encoding)

供給されストリーム特定の文字エンコーディング基づいて、BinaryReader クラス新しインスタンス初期化します。

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

例外例外
例外種類条件

ArgumentException

ストリーム読み取りサポートしていないか、null 参照 (Visual Basic では Nothing) であるか、または既に閉じてます。

ArgumentNullException

encodingnull 参照 (Visual Basic では Nothing) です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

BinaryReader コンストラクタ



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

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

辞書ショートカット

すべての辞書の索引

「BinaryReader コンストラクタ」の関連用語

BinaryReader コンストラクタのお隣キーワード
検索ランキング

   

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



BinaryReader コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS