• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

FileReader TimeOut help  RSS feed

Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone! I hope someone can help me!

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?

Thank you so much!
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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):

If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!