ProjectFileEvent Write to File Method
182535
def _write(self, session, openFile, replaceParamFile=None):
        
        openFile.write(
            text(
                yaml.dump([evt.as_yml() for evt in
                           self.events.order_by(ProjectFileEvent.name,
                           ProjectFileEvent.subfolder)]
                          )
            )
        )
27106
def _send_event_to_project(self, project_id, action, event):
        
        try:
            project_listeners = self._listeners[project_id]
        except KeyError:
            return
        for listener in project_listeners:
            listener.put_nowait((action, event, {}))
1293684
function writeToFileStream(fileStream, filePath) {
  return new Promise((resolve, reject) => {
    const writerStream = fs.createWriteStream(filePath)
      .on('finish', () => resolve(filePath))
      .on('error', err => reject(err));
    fileStream.pipe(writerStream);
  });
}
1075777
def _write_file(folder, filename, data):
    '''
    
    '''
    path = os.path.join(folder, filename)
    if not os.path.exists(folder):
        msg = '{0} cannot be written. {1} does not exist'.format(filename, folder)
        log.error(msg)
        raise AttributeError(six.text_type(msg))
    with salt.utils.files.fopen(path, 'w') as fp_:
        fp_.write(salt.utils.stringutils.to_str(data))

    return 0
1337534
public static void printToFileLn(File file, String message, boolean append) {
    PrintWriter pw = null;
    try {
      Writer fw = new FileWriter(file, append);
      pw = new PrintWriter(fw);
      pw.println(message);
    } catch (Exception e) {
      System.err.println("Exception: in printToFileLn " + file.getAbsolutePath() + ' ' + message);
      e.printStackTrace();
    } finally {
      if (pw != null) {
        pw.flush();
        pw.close();
      }
    }
  }
613943
private File writeFile(final FormFile fileItem) throws Exception {
		final String directory = this.getFileDir(fileItem.getContentType());

		// TODO: ensure unique file names
		final File file = new File(directory + System.currentTimeMillis() + "-"
				+ fileItem.getOriginalFileName());
		fileItem.getFormItem().write(file);
		return file;
	}
109880
private static void generateToCConnectionListener(Map<String, List<TraceEvent>> events, FileWriter fw)
      throws Exception
   {
      writeString(fw, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
      writeEOL(fw);
      writeString(fw, "                      \"http://www.w3.org/TR/html4/loose.dtd\">");
      writeEOL(fw);

      writeString(fw, "<html>");
      writeEOL(fw);

      writeString(fw, "<head>");
      writeEOL(fw);

      writeString(fw, "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">");
      writeEOL(fw);

      writeString(fw, "<title>Reference: ConnectionListener</title>");
      writeEOL(fw);

      writeString(fw, "</head>");
      writeEOL(fw);

      writeString(fw, "<body style=\"background: #D7D7D7;\">");
      writeEOL(fw);

      writeString(fw, "<h1>Reference: ConnectionListener</h1>");
      writeEOL(fw);

      writeString(fw, "<table>");
      writeEOL(fw);
      
      writeString(fw, "<tr>");
      writeEOL(fw);

      writeString(fw, "<td><b>ConnectionListener</b></td>");
      writeEOL(fw);

      writeString(fw, "<td><b>ManagedConnectionPool</b></td>");
      writeEOL(fw);

      writeString(fw, "<td><b>Pool</b></td>");
      writeEOL(fw);

      writeString(fw, "</tr>");
      writeEOL(fw);

      for (Map.Entry<String, List<TraceEvent>> entry : events.entrySet())
      {
         TraceEvent te = entry.getValue().get(0);

         writeString(fw, "<tr>");
         writeEOL(fw);

         writeString(fw, "<td><a href=\"" + te.getPool() + "/" + te.getConnectionListener() + "/index.html\">" +
                     te.getConnectionListener() + "</a></td>");
         writeEOL(fw);
         
         writeString(fw, "<td>" + te.getManagedConnectionPool() + "</td>");
         writeEOL(fw);
      
         writeString(fw, "<td><a href=\"" + te.getPool() + "/index.html\">" + te.getPool() + "</a></td>");
         writeEOL(fw);
      
         writeString(fw, "</tr>");
         writeEOL(fw);
      }

      writeString(fw, "</table>");
      writeEOL(fw);

      writeString(fw, "<p>");
      writeEOL(fw);

      writeString(fw, "<a href=\"index.html\">Back</a>");
      writeEOL(fw);

      writeString(fw, "</body>");
      writeEOL(fw);

      writeString(fw, "</html>");
      writeEOL(fw);
   }
47789
function (event) {
            var
                eventsHandler;
            if (event
                && event.type() === _gpfI.IWritableStream.EVENT_ERROR) {
                gpfFireEvent.call(this, event, this._eventsHandler);
            } else if (0 === this._buffer.length) {
                eventsHandler = this._eventsHandler;
                this._eventsHandler = null;
                gpfFireEvent.call(this, _gpfI.IWritableStream.EVENT_READY, eventsHandler);
            } else {
                this._stream.write(this._buffer.shift(), this._flushed.bind(this));
            }
        }
937357
private void write(IRTMPEvent event, Number streamId) {
        log.trace("write to stream id: {} channel: {}", streamId, id);
        final Header header = new Header();
        final Packet packet = new Packet(header, event);
        // set the channel id
        header.setChannelId(id);
        int ts = event.getTimestamp();
        if (ts != 0) {
            header.setTimer(event.getTimestamp());
        }
        header.setStreamId(streamId);
        header.setDataType(event.getDataType());
        // should use RTMPConnection specific method.. 
        //log.trace("Connection type for write: {}", connection.getClass().getName());
        connection.write(packet);
    }
703204
public static void publishDataToFile(String fileName, int numMessages, int delayInMillis)
      throws IOException {
    PrintWriter out = new PrintWriter(new OutputStreamWriter(
        new BufferedOutputStream(new FileOutputStream(fileName, true)), "UTF-8"));

    try {
      for (int i = 0; i < Math.max(1, numMessages); i++) {
        Long currTime = System.currentTimeMillis();
        String message = generateEvent(currTime, delayInMillis);
        out.println(message);
      }
    } catch (Exception e) {
      System.err.print("Error in writing generated events to file");
      e.printStackTrace();
    } finally {
      out.flush();
      out.close();
    }
  }
314613
private void writeCalendar(ProjectCalendar record) throws IOException
   {
      //
      // Test used to ensure that we don't write the default calendar used for the "Unassigned" resource
      //
      if (record.getParent() == null || record.getResource() != null)
      {
         m_buffer.setLength(0);

         if (record.getParent() == null)
         {
            m_buffer.append(MPXConstants.BASE_CALENDAR_RECORD_NUMBER);
            m_buffer.append(m_delimiter);
            if (record.getName() != null)
            {
               m_buffer.append(record.getName());
            }
         }
         else
         {
            m_buffer.append(MPXConstants.RESOURCE_CALENDAR_RECORD_NUMBER);
            m_buffer.append(m_delimiter);
            m_buffer.append(record.getParent().getName());
         }

         for (DayType day : record.getDays())
         {
            if (day == null)
            {
               day = DayType.DEFAULT;
            }
            m_buffer.append(m_delimiter);
            m_buffer.append(day.getValue());
         }

         m_buffer.append(MPXConstants.EOL);
         m_writer.write(m_buffer.toString());

         ProjectCalendarHours[] hours = record.getHours();
         for (int loop = 0; loop < hours.length; loop++)
         {
            if (hours[loop] != null)
            {
               writeCalendarHours(record, hours[loop]);
            }
         }

         if (!record.getCalendarExceptions().isEmpty())
         {
            //
            // A quirk of MS Project is that these exceptions must be
            // in date order in the file, otherwise they are ignored.
            // The getCalendarExceptions method now guarantees that
            // the exceptions list is sorted when retrieved.
            //
            for (ProjectCalendarException ex : record.getCalendarExceptions())
            {
               writeCalendarException(record, ex);
            }
         }

         m_eventManager.fireCalendarWrittenEvent(record);
      }
   }
130272
public void writeToFile(StringBuffer content, String filename) throws NoSuchPathException, IOException{
		try {
			FileWriter input = new FileWriter(filename);
			input.write(content.toString(), 0, content.length());
			input.flush();
			input.close();
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		}
	}
607607
public static void writeToFile(String pFileName, String pContents, boolean pAppend)
     throws IOException{
         FileWriter writer = null;
         writer = new FileWriter(pFileName, pAppend);
         writer.write(pContents);
         writer.flush();
         writer.close();

    }
799192
private Event fileToEvent(File eventFile) {
        Object eventObj;

        try (FileInputStream fileInputStream = new FileInputStream(new File(eventFile.getAbsolutePath()));
             ObjectInputStream ois = new ObjectInputStream(fileInputStream)) {
            eventObj = ois.readObject();
        } catch (FileNotFoundException e) {
            // event was deleted while we were iterating the array of files
            return null;
        } catch (Exception e) {
            logger.error("Error reading Event file: " + eventFile.getAbsolutePath(), e);
            if (!eventFile.delete()) {
                logger.warn("Failed to delete Event: " + eventFile.getAbsolutePath());
            }
            return null;
        }

        try {
            return (Event) eventObj;
        } catch (Exception e) {
            logger.error("Error casting Object to Event: " + eventFile.getAbsolutePath(), e);
            if (!eventFile.delete()) {
                logger.warn("Failed to delete Event: " + eventFile.getAbsolutePath());
            }
            return null;
        }
    }
1209522
function writeFile(pathToFile, content, verbose) {
  var directory = _path2.default.dirname(pathToFile);

  // Create directory if it doesn't exist
  if (!_fs2.default.existsSync(directory)) {
    _fs2.default.mkdirSync(directory);
  }

  // Try to write file to disk to the given location
  _fs2.default.writeFile(pathToFile, content, { flag: 'w' }, function (error) {
    if (error) {
      throw new Error(error);
    }

    // Log success message to the console if in verbose mode only
    if (verbose) {
      var successMessage = '\nVersion file written to ' + _chalk2.default.green(pathToFile);

      console.log(successMessage);
    }
  });
}
1131747
private void makeNewFile() throws IOException {
		String filename=prefix+(files.size()+1)+suffix;
		File file=new File(parent, filename);
		out=new FileOutputStream(file);
		bytesOut=0;
		files.add(file);
	}
557649
private void writeCalendars(Project project)
   {
      //
      // Create the new MSPDI calendar list
      //
      Project.Calendars calendars = m_factory.createProjectCalendars();
      project.setCalendars(calendars);
      List<Project.Calendars.Calendar> calendar = calendars.getCalendar();

      //
      // Process each calendar in turn
      //
      for (ProjectCalendar cal : m_projectFile.getCalendars())
      {
         calendar.add(writeCalendar(cal));
      }
   }