protected String validateMetaLine ( String metaLineStr ) throws IOException { if ( metaLineStr . length ( ) > MAX_METADATA_LINE_LENGTH ) { throw new IOException ( "Metadata line too long (" + metaLineStr . length ( ) + ">" + MAX_METADATA_LINE_LENGTH + "): " + metaLineStr ) ; } Matcher m = METADATA_LINE_PATTERN . matcher ( metaLineStr ) ; if ( ! m . matches ( ) ) { throw new IOException ( "Metadata line doesn't match expected" + " pattern: " + metaLineStr ) ; } return metaLineStr ; }
Test that the metadata line is valid before writing .