Skip to content

kiwi.io.BufferedReader

Nikos Siatras edited this page Oct 8, 2022 · 16 revisions

BufferedReader reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.

CAUTION: Although the following code example explains how to read a Unicode file, BufferedReader does not currently support Unicode text files.

Constructor

constructor(byref reader as InputStreamReader)

Creates a new BufferedReader instance @param reader is the input reader to use with this buffered reader

BufferedReader.OpenStream()

function BufferedReader.OpenStream() as Boolean

Opens the Input Stream
@return true if file exists and can be read

BufferedReader.CloseStream()

function BufferedReader.OpenStream() as Boolean

Closes the Input Stream

BufferedReader.hasNextLine()

function BufferedReader.hasNextLine() as Boolean

Returns true if this BufferedReader has a next line.

BufferedReader.readLine()

function BufferedReader.readLine() as String

Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a line feed, or by reaching the end-of-file (EOF).

BufferedReader Examples

Example - Read a File line-by-line

#include once "kiwi\kiwi.bi"
#include once "kiwi\io.bi" ' Include Kiwi's IO package

' Initialize a File and a FileReader
Dim myFile as File = File("C:\Users\nsiat\Desktop\Test.txt")
Dim myReader as FileReader = FileReader(myFile, Charset.UTF8) ' Use UTF-8 Charset

' Initialize a BufferedReader. The BufferedReader will be used to
' read the text file line-by-line
Dim bReader as BufferedReader = BufferedReader(myReader)

if bReader.OpenStream() = true then
	while bReader.hasNextLine()
		print bReader.readLine() ' Print each line of the text file
	wend
	bReader.CloseStream() ' Close the Stream
else
	print "Unable to open the file! Check if file is saved as 'UTF-8-BOM'"
end if

Home

Kiwi.DB

  • MySQL/MariaDB - Coming to v1.0.2

Kiwi.IO

Kiwi.lang

Kiwi.locale

Kiwi.time

Kiwi.util

Clone this wiki locally