void writeWithThumbs(ImageOutputStream ios,List thumbnails,JPEGImageWriter writer) throws IOException {
  if (thumbnails != null) {
    JFIFExtensionMarkerSegment jfxx=null;
    if (thumbnails.size() == 1) {
      if (!extSegments.isEmpty()) {
        jfxx=(JFIFExtensionMarkerSegment)extSegments.get(0);
      }
      writeThumb(ios,(BufferedImage)thumbnails.get(0),jfxx,0,true,writer);
    }
 else {
      write(ios,writer);
      for (int i=0; i < thumbnails.size(); i++) {
        jfxx=null;
        if (i < extSegments.size()) {
          jfxx=(JFIFExtensionMarkerSegment)extSegments.get(i);
        }
        writeThumb(ios,(BufferedImage)thumbnails.get(i),jfxx,i,false,writer);
      }
    }
  }
 else {
    write(ios,writer);
  }
}

void writeWithThumbs ( ImageOutputStream ios , List thumbnails , JPEGImageWriter writer ) throws IOException { if ( thumbnails != null ) { JFIFExtensionMarkerSegment jfxx = null ; if ( thumbnails . size ( ) == 1 ) { if ( ! extSegments . isEmpty ( ) ) { jfxx = ( JFIFExtensionMarkerSegment ) extSegments . get ( 0 ) ; } writeThumb ( ios , ( BufferedImage ) thumbnails . get ( 0 ) , jfxx , 0 , true , writer ) ; } else { write ( ios , writer ) ; for ( int i = 0 ; i < thumbnails . size ( ) ; i ++ ) { jfxx = null ; if ( i < extSegments . size ( ) ) { jfxx = ( JFIFExtensionMarkerSegment ) extSegments . get ( i ) ; } writeThumb ( ios , ( BufferedImage ) thumbnails . get ( i ) , jfxx , i , false , writer ) ; } } } else { write ( ios , writer ) ; } }
write out this jfif marker segment , including a thumbnail or appending a series of jfxx marker segments , as appropriate . warnings and progress reports are sent to the writer argument . the list of thumbnails is matched to the list of jfxx extension segments , if any , in order to determine how to encode the thumbnails . if there are more thumbnails than metadata segments , default encoding is used for the extra thumbnails .
