I'm displaying streaming content using a file to buffer it (because it could be large enough to keep it in RAM). I have two threads: the first downloads a file from server and writes it to the local storage, and the second reads that file and displays the content.
The problem is, when the second thread reaches the end of the file, EOFException
is thrown from DataInputStream.readFully()
method. Is there any way to make it wait while the first thread writes enough data instead of throwing exception?