Can I set a timeout for a InputStream's read() function?
        Posted  
        
            by Zombies
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Zombies
        
        
        
        Published on 2010-04-14T14:41:28Z
        Indexed on 
            2010/04/14
            14:43 UTC
        
        
        Read the original article
        Hit count: 249
        
I have a DataInputStream that I obtained from a Socket. Is there any way I can set a timeout for dis.read(...)? Currently I spawn a new thread to do the read. While the parent thread does a thread.join(timeout) to wait before interrupting it. I am aware of nio, but I don't think I want to refactor that much at this point. Thanks.
© Stack Overflow or respective owner