Buggy code:
} else if ( fieldName . equalsIgnoreCase ( "name" ) ) { vname = item . getString ( ) ; } else if ( fieldName . equalsIgnoreCase ( "info" ) ) { info = Comment . toDatabase ( item . getString ( ) ) ; } else if ( fieldName . equalsIgnoreCase ( "supervisors" ) ) { String tch = item . getString ( ) ; while ( tch . contains ( "'" ) ) { supervisors . add ( tch . substring ( 0 , tch . indexOf ( "'" ) ) ) ; tch = tch . substring ( ( ( tch . indexOf ( "'" ) ) + 1 ) ) ; } } else if ( fieldName . equalsIgnoreCase ( "assessors" ) ) { String tch = item . getString ( ) ; while ( tch . contains ( "'" ) ) { assessors . add ( tch . substring ( 0 , tch . indexOf ( "'" ) ) ) ; tch = tch . substring ( ( ( tch . indexOf ( "'" ) ) + 1 ) ) ; } } } else { String fileName = item . getName ( ) ; filePath = this . getServletContext ( ) . getRealPath ( "//temp" ) ; File tempFolder = new File ( filePath ) ; if ( ! ( tempFolder . exists ( ) ) ) tempFolder . mkdir ( ) ; filePath = ( filePath + ( File . separatorChar ) ) + fileName ; item . write ( new File ( filePath ) ) ; } } if ( ( ( ( pid == null ) || ( ( student . length ( ) ) == 0 ) ) || ( ( vname . length ( ) ) == 0 ) ) || ( ( filePath . length ( ) ) == 0 ) ) { svct . getRequestDispatcher ( "//manage//upload-fail.jsp" ) . forward ( request , response ) ; return ; } String newPath = ( ( ( ( ( ( this . getServletContext ( ) . getRealPath ( "//" ) ) + ( File . separatorChar ) ) + pid ) + ( File . separatorChar ) ) + student ) + "_" ) + vname ; ArrayList < String > command = new ArrayList < String > ( ) ; command . add ( "ffprobe" ) ; command . add ( filePath ) ; Process checkCodec = new ProcessBuilder ( command ) . redirectErrorStream ( true ) . start ( ) ; Scanner sc = new Scanner ( checkCodec . getInputStream ( ) ) ; Double duration = 0.0 ; boolean h264 = false ; boolean aac = false ; boolean small = false ; while ( sc . hasNextLine ( ) ) { String str = sc . nextLine ( ) ; if ( str . contains ( "Duration:<seq2seq4repair_space>" ) ) { str = str . substring ( ( ( str . indexOf ( ':' ) ) + 2 ) ) ; duration = Double . parseDouble ( str . substring ( 0 , str . indexOf ( ':' ) ) ) ; str = str . substring ( ( ( str . indexOf ( ':' ) ) + 1 ) ) ; duration = ( duration * 60 ) + ( Double . parseDouble ( str . substring ( 0 , str . indexOf ( ':' ) ) ) ) ; str = str . substring ( ( ( str . indexOf ( ':' ) ) + 1 ) ) ; duration = ( duration * 60 ) + ( Double . parseDouble ( str . substring ( 0 , str . indexOf ( ',' ) ) ) ) ; } else if ( ( str . contains ( "Stream<seq2seq4repair_space>" ) ) && ( str . contains ( "Video:<seq2seq4repair_space>" ) ) ) { if ( str . contains ( "h264" ) ) h264 = true ; <START_BUG> str = str . substring ( str . indexOf ( ",<seq2seq4repair_space>" ) ) ; <END_BUG> str = str . substring ( ( ( str . indexOf ( ",<seq2seq4repair_space>" ) ) + 2 ) ) ; int minIndex = str . indexOf ( ',' ) ; if ( ( str . indexOf ( '<seq2seq4repair_space>' ) ) < minIndex ) minIndex = str . indexOf ( '<seq2seq4repair_space>' ) ; int width = Integer . parseInt ( str . substring ( 0 , str . indexOf ( 'x' ) ) ) ; int height = Integer . parseInt ( str . substring ( ( ( str . indexOf ( 'x' ) ) + 1 ) , minIndex ) ) ; if ( width <= 800 ) small = true ; } else if ( ( ( str . contains ( "Stream<seq2seq4repair_space>" ) ) && ( str . contains ( "Audio:<seq2seq4repair_space>" ) ) ) && ( str . contains ( "aac" ) ) ) { aac = true ; } } sc . close ( ) ; if ( duration == 0 ) { svct . getRequestDispatcher ( "//manage//upload-fail.jsp" ) . forward ( request , response ) ; return ; } Connection conn = MySqlConnection . getConnection ( ) ; Statement stmt = conn . createStatement ( ) ; stmt . executeUpdate ( ( ( ( ( ( ( ( ( ( "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>Video<seq2seq4repair_space>(project,student,name,info,status)" + "VALUES(" ) + pid ) + ",'" ) + student ) + "','" ) + vname ) + "','" ) + info ) + ( ( h264 && aac ) && small ? "',50)" : "',0)" ) ) ) ; ResultSet rs = stmt . executeQuery ( "SELECT<seq2seq4repair_space>LAST_INSERT_ID()" ) ; rs . next ( ) ; int vid = rs . getInt ( 1 ) ; rs . close ( ) ; for ( String tch : supervisors ) { stmt . executeUpdate ( ( ( ( ( ( "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>Assess<seq2seq4repair_space>(video,teacher,teacherRight)" + "VALUES(" ) + vid ) + ",'" ) + tch ) + "',2)" ) ) ; }

Fix:
str = str . substring ( ( ( str . indexOf ( ",<seq2seq4repair_space>" ) ) + 2 ) ) ;