Code example for BufferedWriter

Methods: close, write

0
    try { 
      File res = File.createTempFile(FILE_NAME, ".js");
      res.deleteOnExit();
      Writer
          writer =
          new BufferedWriter(new OutputStreamWriter(new FileOutputStream(res), "UTF-8"));
      writer.write(content);
      writer.close();
      return res;
    } catch (Exception e) {
      throw new WebDriverException("Cannot generate script."); 
    } 
 
  } 
 
  public File getScript(int port, String aut, String opaqueKey) {
    try { 
      String content = generateScriptContent(port, aut, opaqueKey);
      return createTmpScript(content);
    } catch (Exception e) {
      throw new WebDriverException("cannot generate the script for instrument.", e);