public synchronized ServerStatusMessage [ ] getMessages ( ServerStatusMessage afterMessage ) throws Exception { boolean sawAfterMessage ; String afterMessageString = null ; if ( afterMessage == null ) { sawAfterMessage = true ; } else { sawAfterMessage = false ; afterMessageString = afterMessage . toString ( ) ; } FileInputStream in = null ; try { in = new FileInputStream ( _file ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; List < ServerStatusMessage > messages = new ArrayList < ServerStatusMessage > ( ) ; ServerStatusMessage message = getNextMessage ( reader ) ; while ( message != null ) { if ( ! sawAfterMessage ) { if ( message . toString ( ) . equals ( afterMessageString ) ) { sawAfterMessage = true ; } } else { messages . add ( message ) ; } message = getNextMessage ( reader ) ; } return messages . toArray ( STATUS_MSG_ARRAY_TYPE ) ; } catch ( IOException ioe ) { throw new Exception ( "Error opening server status file for reading: " + _file . getPath ( ) , ioe ) ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( Exception e ) { } } } }
Get all messages in the status file or only those after the given message if it is non - null . If the status file doesn t exist or can t be parsed throw an exception .