public static File stream2file(InputStream in) throws IOException {
  final File tempFile=File.createTempFile(PREFIX,SUFFIX);
  try (FileOutputStream out=new FileOutputStream(tempFile)){
    IOUtils.copy(in,out);
  }
   String newFont=getFontForOS();
  if (newFont.compareToIgnoreCase(DEFAULT_FONT) != 0) {
    BufferedReader br=new BufferedReader(new FileReader(tempFile));
    try {
      StringBuilder sb=new StringBuilder();
      String line=br.readLine();
      while (line != null) {
        sb.append(line.replace(DEFAULT_FONT,newFont));
        sb.append("\n");
        line=br.readLine();
      }
      try {
        FileWriter fileWriter=new FileWriter(tempFile);
        fileWriter.write(sb.toString());
        fileWriter.flush();
        fileWriter.close();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  finally {
      br.close();
    }
  }
  return tempFile;
}

public static File stream2file ( InputStream in ) throws IOException { final File tempFile = File . createTempFile ( PREFIX , SUFFIX ) ; try ( FileOutputStream out = new FileOutputStream ( tempFile ) ) { IOUtils . copy ( in , out ) ; } String newFont = getFontForOS ( ) ; if ( newFont . compareToIgnoreCase ( DEFAULT_FONT ) != 0 ) { BufferedReader br = new BufferedReader ( new FileReader ( tempFile ) ) ; try { StringBuilder sb = new StringBuilder ( ) ; String line = br . readLine ( ) ; while ( line != null ) { sb . append ( line . replace ( DEFAULT_FONT , newFont ) ) ; sb . append ( "\n" ) ; line = br . readLine ( ) ; } try { FileWriter fileWriter = new FileWriter ( tempFile ) ; fileWriter . write ( sb . toString ( ) ) ; fileWriter . flush ( ) ; fileWriter . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } finally { br . close ( ) ; } } return tempFile ; }
writes an inputstream to a temporary file .
