Buggy code:
public class TrainingDataHTMLGen { public static String htmlFromAnnotations ( List < Pair < List < MsgAnnotation > , String > > annotatedMsgBlocks , List < Pair < String , String > > base64EncodedFiles , String auxtext ) throws Exception { HashMap < String , Dimension > imageSizes = new HashMap < String , Dimension > ( ) ; for ( Pair < String , String > p : base64EncodedFiles ) { BufferedImage img = imageFromBase64Encoded ( p . Item2 ) ; imageSizes . put ( p . Item1 , new Dimension ( img . getWidth ( ) , img . getHeight ( ) ) ) ; } int i = 0 ; List < String > j = new ArrayList < String > ( ) ; List < String > h = new ArrayList < String > ( ) ; for ( Pair < List < MsgAnnotation > , String > annotationAndText : annotatedMsgBlocks ) { List < MsgAnnotation > annotationList = annotationAndText . Item1 ; String blockText = annotationAndText . Item2 ; String blockTextMinusForeign = excludeForeignMsgStr ( blockText ) ; String msgtext = textFromMsgIdBlock ( blockText ) ; String foreigntext = foreignTextFromMsgIdBlock ( blockText ) ; String encmsgtext = URLEncoder . encode ( msgtext , "UTF-8" ) ; int totalImageWidth = 0 ; int maxImageHeight = 0 ; for ( MsgAnnotation annotation : annotationList ) { int imageWidth = ( imageSizes . get ( annotation . filename ) . width ) + 10 ; int imageHeight = imageSizes . get ( annotation . filename ) . height ; totalImageWidth += imageWidth ; maxImageHeight = Math . max ( imageHeight , maxImageHeight ) ; } h . add ( ( ( ( ( "<div<seq2seq4repair_space>style='width:<seq2seq4repair_space>" + totalImageWidth ) + ";<seq2seq4repair_space>height:<seq2seq4repair_space>" ) + ( maxImageHeight + 10 ) ) + ";<seq2seq4repair_space>overflow:<seq2seq4repair_space>auto;<seq2seq4repair_space>white-space:<seq2seq4repair_space>nowrap;'>" ) ) ; int jc = 0 ; for ( MsgAnnotation annotation : annotationList ) { Integer [ ] coordinates = new Integer [ ] { annotation . x , annotation . y , annotation . w , annotation . h } ; String coordargs = join ( coordinates , "," ) ; String canvasname = ( ( "c" + encmsgtext ) + "-" ) + jc ; int imageWidth = imageSizes . get ( annotation . filename ) . width ; int imageHeight = imageSizes . get ( annotation . filename ) . height ; String highlightData = ( ( ( ( ( ( ( ( ( ( ( ( HTMLGen . imagesDir ) + imageWidth ) + "-" ) + imageHeight ) + "-" ) + ( annotation . x ) ) + "-" ) + ( annotation . y ) ) + "-" ) + ( annotation . w ) ) + "-" ) + ( annotation . h ) ) + ".png" ; <START_BUG> if ( ( ! ( HTMLGen . imagesDir . startsWith ( "http" ) ) ) && ( ! ( new File ( ( "..//" + highlightData ) ) . exists ( ) ) ) ) { <END_BUG> ImageIO . write ( GImageUtils . GImageUtils . transparentRectangle ( new Dimension ( imageWidth , imageHeight ) , annotation . x , annotation . y , annotation . w , annotation . h ) , "png" , new File ( ( "..//" + highlightData ) ) ) ; } String filename = annotation . filename ; while ( ( count ( filename , '//' ) ) > 1 ) { filename = filename . substring ( ( ( filename . indexOf ( '//' ) ) + 1 ) ) ; } h . add ( ( ( ( ( ( ( ( ( ( ( "<img<seq2seq4repair_space>id='" + canvasname ) + "'<seq2seq4repair_space>width=" ) + imageWidth ) + "<seq2seq4repair_space>height=" ) + imageHeight ) + "<seq2seq4repair_space>src='" ) + highlightData ) + "\'<seq2seq4repair_space>style=\'background-image:<seq2seq4repair_space>url(\"" ) + filename ) + "\")\'><//img>" ) ) ; jc += 1 ; } h . add ( "<//div>" ) ; h . add ( ( ( "<div<seq2seq4repair_space>style='width:<seq2seq4repair_space>" + totalImageWidth ) + ";<seq2seq4repair_space>height:<seq2seq4repair_space>30;<seq2seq4repair_space>overflow:<seq2seq4repair_space>auto;<seq2seq4repair_space>white-space:<seq2seq4repair_space>nowrap;'>" ) ) ; int totalImgW = 0 ; jc = 0 ; for ( MsgAnnotation annotation : annotationList ) { int imageWidth = ( imageSizes . get ( annotation . filename ) . width ) + 10 ; String id = ( ( ( "'q-" + encmsgtext ) + "-" ) + jc ) + "'" ; String style = ( "<seq2seq4repair_space>style='position:<seq2seq4repair_space>absolute;<seq2seq4repair_space>left:<seq2seq4repair_space>" + totalImgW ) + "'<seq2seq4repair_space>" ; String style2 = ( "<seq2seq4repair_space>style='position:<seq2seq4repair_space>absolute;<seq2seq4repair_space>left:<seq2seq4repair_space>" + ( totalImgW + 20 ) ) + "'<seq2seq4repair_space>" ; h . add ( ( ( ( ( ( ( ( ( ( ( ( "<input<seq2seq4repair_space>type='checkbox'<seq2seq4repair_space>name=" + id ) + "<seq2seq4repair_space>id=" ) + id ) + style ) + totalImgW ) + "'<seq2seq4repair_space>//><label<seq2seq4repair_space>for=" ) + id ) + style2 ) + ">Image<seq2seq4repair_space>" ) + jc ) + "<seq2seq4repair_space>Matches<//label>" ) ) ; totalImgW += imageWidth ; jc += 1 ; } String id = ( "'qn-" + encmsgtext ) + "'" ; h . add ( ( ( ( ( ( ( ( ( ( ( "<input<seq2seq4repair_space>type='checkbox'<seq2seq4repair_space>name=" + id ) + "<seq2seq4repair_space>id=" ) + id ) + "<seq2seq4repair_space>style='position:<seq2seq4repair_space>absolute;<seq2seq4repair_space>left:<seq2seq4repair_space>" ) + totalImgW ) + "'<seq2seq4repair_space>//><label<seq2seq4repair_space>for=" ) + id ) + "<seq2seq4repair_space>style='position:<seq2seq4repair_space>absolute;<seq2seq4repair_space>left:<seq2seq4repair_space>" ) + ( totalImgW + 20 ) ) + ";<seq2seq4repair_space>border:<seq2seq4repair_space>none'>None<seq2seq4repair_space>Match<//div>" ) ) ; h . add ( "<//div>" ) ; h . add ( ( ( "<b>" + msgtext ) + "<//b><br//><br//>" ) ) ; i += 1 ; } List < String > o = new ArrayList < String > ( ) ; o . add ( "<html>" ) ; o . add ( "<head>" ) ; o . add ( "<//head>" ) ; o . add ( "<body>" ) ; o . add ( "<form<seq2seq4repair_space>method='post'<seq2seq4repair_space>action='http:////gkovacs.xvm.mit.edu:8080//textmatch-manual-labeled.jsp'>" ) ; o . add ( "<input<seq2seq4repair_space>type='submit'<seq2seq4repair_space>name='button'<seq2seq4repair_space>value='Download<seq2seq4repair_space>Annotated<seq2seq4repair_space>Message<seq2seq4repair_space>File'<seq2seq4repair_space>//><br//><br//>" ) ; o . add ( auxtext ) ; o . add ( join ( h , "\n" ) ) ; o . add ( "<//form>" ) ; o . add ( "<//body>" ) ; o . add ( "<//html>" ) ;

Fix:
if ( ( ( ! ( HTMLGen . imagesDir . startsWith ( "http" ) ) ) && ( ! ( new File ( ( "..//" + highlightData ) ) . exists ( ) ) ) ) && ( new File ( ( "..//" + ( HTMLGen . imagesDir ) ) ) . exists ( ) ) ) {