close

Java Flushing Output with the Flush Method - Send Buffer to Output Stream - APPFICIAL

in this video we're gonna talk about

flushing output so a buffer is a portion

of memory that's used to store a stream

of data or characters and those

characters sometime only get sent to an

output device such as a monitor when the

buffer is full or meets a certain number

of characters and this can cause your

system to lag if you just have a few

characters that you want sent to an

output device so using the flush method

will immediately flush the contents of

the buffer to the output stream and

let's see why this can be useful and

important so back in this write file

class we have a program that writes a

text file called my file that text and

it prints out I love Java and the number

56 to it and then watch what happens if

I don't close the file I'm going to

remove PW close and because there wasn't

enough things in the buffer it didn't

get it's not gonna get rid into the file

and also because I'm not closing the

file which flushes the buffer so it says

it says the file was written too but

let's take a look and refresh the Java

package and look inside my PI a lot text

and it's empty these files did not get

written to it because I removed the PW

close if I do the PW blush and forgot to

close the stream it will guarantee that

the file just written too so let's check

it now here's the data just to be safe

call the flush method when you're ready

to write the stuff to the file and not

have to wait for the file to be closed

you should still do anyways

you