public String generateDataURI(final InputStream inputStream,final String fileName) throws IOException {
  final StringWriter writer=new StringWriter();
  final byte[] bytes=IOUtils.toByteArray(inputStream);
  inputStream.close();
  final String mimeType=getMimeType(fileName);
  generateDataURI(bytes,writer,mimeType);
  return writer.toString();
}

public String generateDataURI ( final InputStream inputStream , final String fileName ) throws IOException { final StringWriter writer = new StringWriter ( ) ; final byte [ ] bytes = IOUtils . toByteArray ( inputStream ) ; inputStream . close ( ) ; final String mimeType = getMimeType ( fileName ) ; generateDataURI ( bytes , writer , mimeType ) ; return writer . toString ( ) ; }
generate the datauri as string associated to the passed inputstream with encoding & type based on provided filename .
