StreamReader.Read reads the next character from the input stream : Stream Reader « File Directory « VB.Net






StreamReader.Read reads the next character from the input stream

 

Imports System
Imports System.IO
Imports System.Text

Public Class Test
    Public Shared Sub Main()
        Dim path As String = "c:\temp\MyTest.txt"
        Try
            If File.Exists(path) Then
                File.Delete(path)
            End If
            Dim sw As StreamWriter = New StreamWriter(path)
            sw.WriteLine("this is a test")
            sw.WriteLine("this is a test")
            sw.WriteLine("this is a test")
            sw.WriteLine("this is a test")
            sw.Close()

            Dim sr As StreamReader = New StreamReader(path)
            Do While sr.Peek() >= 0
                Console.Write(Convert.ToChar(sr.Read()))
            Loop
            sr.Close()
        Catch e As Exception
            Console.WriteLine("The process failed: {0}", e.ToString())
        End Try
    End Sub
End Class

   
  








Related examples in the same category

1.Read all file contentRead all file content
2.Stream Reader DemoStream Reader Demo
3.Stream Reader: read intStream Reader: read int
4.StreamReader Class implements a TextReader that reads characters from a byte stream in a particular encoding.
5.Create StreamReader class for the specified stream.
6.Create StreamReader class for the specified file name.
7.Display Integer read from a StreamReader in hex format
8.StreamReader Class Implements a TextReader that reads characters from a byte stream in a particular encoding.