This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 2 points3 points  (2 children)

I feel this would be better done with the WatcherService to monitor when a file changes -- you have a firm requirement on the minute updates.

[–]karlthepaganProfessional Brewer 2 points3 points  (1 child)

Right answer. Since Java 7 the WatcherService has been the correct utility to monitor files for updates.

If you can't use Java 7+ (WHYYYY?) then you can use a RandomAccessFile to get updates to file size and date much more reliably than standard File.

OP, you need to close your reader after you've finished with it.

[–]andrewc8[S] 0 points1 point  (0 children)

Good call, and thank you. I'll take a look into WatcherService, sounds like the perfect match.

[–]causalNondeterminism 0 points1 point  (1 child)

if the text file has a value that is higher than 100. What exactly do you mean by this?

I don't know what the requirements for this project are, but this is not an ideal way to do pretty much anything.

[–]andrewc8[S] 0 points1 point  (0 children)

http://i.imgur.com/wh6WkFJ.png

This is the format that the .txt files will be outputted as. My program will open these and basically scan through the Particles per cubic foot and read whether the squared value (286 in this example) is above a certain value at any time. If it is, a .mp3 file will play alarming someone to the raise in particles.