I'm working in an application which needs to read a txt file over the network (is an application running in a client and the file is in a server). I noticed that, when I'm having network problems, the application hangs and I get the gray window.
Checking about this I found that the problem was because of a FileReader that was looking for the file while disconnected from the network. Is there any way to set up de FileReader's timeout, so it lasts no more than 4 seconds?
I could think of the only way to add pause to FileReader - to create separate thread, which will watch reading time and report timeouts. For example, like this (for simplicity i overrode only read() method):