Code example for PrintStream

Methods: flush, print

0
  /** 
   * Writes a newline to the log file, and updates the line counters. Handles 
   * flushing. 
   */ 
  private void finishLogLine() { 
    out.print("\n");
 
    // flush the buffer every 100 lines 
    lineCount++;
    if ((lineCount % 100) == 0) {
      out.flush();
    } 
  } 
 
  /** 
   * Returns the text we should write to the file for a given sensor ID. 
   */ 
  private static String getSensorName(int sensorId) {
    switch (sensorId) {
      case Sensor.TYPE_ACCELEROMETER:
        return "accel";