private void detectFileChange ( ) throws IOException { checkClosed ( ) ; assert Thread . holdsLock ( filePosLock ) ; while ( ! file . exists ( ) ) { try { System . err . println ( "File not found, waiting: " + file . getPath ( ) ) ; Thread . sleep ( pollInterval ) ; } catch ( InterruptedException e ) { InterruptedIOException newExc = new InterruptedIOException ( e . getMessage ( ) ) ; newExc . initCause ( e ) ; throw newExc ; } checkClosed ( ) ; } long fileLen = file . length ( ) ; if ( fileLen < filePos ) filePos = 0 ; }
Checks the current position in the file . Detects if the file has changed in length . If closed throws an exception . If file doesn t exist waits until it does exist .