I need to know what is exact difference between flush and close function in Java?

And When the data is dumped into a file during writing of file?

Please provide one example

Edit
Report