I've got this soure:
public static void inBufferBooks() throws IOException
{
Reader inStreamBooks = null;
BufferedReader bufferIn = null;
try
{
inStreamBooks = new FileReader("Files/BufferBook.txt");
bufferIn = new BufferedReader(inStreamBooks);
char text[] = new char[10];
int i = -1;
while ((i = inStreamBooks.read(text, 0, 10)) != -1)
{
System.out.print(text);
}
When I read file at the end of the text console printing chars who's fill last array. How can I read whole text from the file without redundant chars from last array?
Use the value
read
returns to you to determine how many characters in the array are still valid. From the documentation: