public String writeImageFile(byte[] imageBytes,String outputPath,boolean checkFormatterForExtension) throws IOException {
  String appendix="";
  if (checkFormatterForExtension) {
    ImageFormatter formatter=getFormatter();
    if (formatter == null) {
      appendix=".jpg";
    }
 else {
      String fileType=formatter.getFormatLabel();
      if (fileType.equals(WMTConstants.IMAGEFORMAT_JPEG)) {
        appendix=".jpg";
      }
 else {
        appendix="." + fileType.toLowerCase();
      }
    }
    if (outputPath.endsWith(appendix)) {
      appendix="";
    }
  }
  String finalOutputPath=outputPath + appendix;
  FileOutputStream fos=new FileOutputStream(finalOutputPath);
  fos.write(imageBytes);
  fos.flush();
  fos.close();
  return finalOutputPath;
}

public String writeImageFile ( byte [ ] imageBytes , String outputPath , boolean checkFormatterForExtension ) throws IOException { String appendix = "" ; if ( checkFormatterForExtension ) { ImageFormatter formatter = getFormatter ( ) ; if ( formatter == null ) { appendix = ".jpg" ; } else { String fileType = formatter . getFormatLabel ( ) ; if ( fileType . equals ( WMTConstants . IMAGEFORMAT_JPEG ) ) { appendix = ".jpg" ; } else { appendix = "." + fileType . toLowerCase ( ) ; } } if ( outputPath . endsWith ( appendix ) ) { appendix = "" ; } } String finalOutputPath = outputPath + appendix ; FileOutputStream fos = new FileOutputStream ( finalOutputPath ) ; fos . write ( imageBytes ) ; fos . flush ( ) ; fos . close ( ) ; return finalOutputPath ; }
takes a byte array and writes it out to a file path .
