Send a file full of events to the collector. This does zero-bytes-copy by default (the async-http-client does
it for us).

@param file    File to send
@param handler callback handler for the serialization-writer library
492997
@Override
    public void send(final File file, final CallbackHandler handler)
    {
        log.info("Sending local file to collector: {}", file.getAbsolutePath());
        final long startTime = System.nanoTime();

        final AsyncCompletionHandler<Response> asyncCompletionHandler = new AsyncCompletionHandler<Response>()
        {
            @Override
            public Response onCompleted(final Response response)
            {
                activeRequests.decrementAndGet();

                if (response.getStatusCode() == 202) {
                    handler.onSuccess(file);
                }
                else {
                    handler.onError(new IOException(String.format("Received response %d: %s",
                                                                  response.getStatusCode(), response.getStatusText())), file);
                }

                sendTimer.update(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
                return response; // never read
            }

            @Override
            public void onThrowable(final Throwable t)
            {
                activeRequests.decrementAndGet();
                handler.onError(t, file);
            }
        };

        final HttpJob job = new HttpJob(client, file, asyncCompletionHandler);
        workers.offer(job);
    }
216632
public final void process(final File file) {
        if (file == null) {
            throw new IllegalArgumentException("Argument 'file' cannot be NULL");
        }
        if (file.isFile()) {
            handler.handleFile(file);
        } else {
            processDir(file);
        }
    }
836558
function readFile(file, callback){

		// Run this sequentially
		sync(function(){
			// Create a new FileReader Object
			var reader = new FileReader();

			// Set an onload handler because we load files into it Asynchronously
			reader.onload = function(e){

				// Print onto Canvas
				callback( this.result );

				// Run the next one;
				sync();
			};

			reader.readAsDataURL(file);
		});
	}
1265577
public void write(File file) throws IOException {
        try (InputStream inputStream = getInputStream()) {
            IoUtils.copy(inputStream, file);
        }
    }
740048
private List<LogEntry> createScribePayload(final File file, final CallbackHandler handler)
    {
        try {
            final List<Event> events = Events.fromFile(file);
            final List<LogEntry> list = new ArrayList<LogEntry>(events.size());

            for (final Event event : events) {
                final String logEntryMessage = eventToLogEntryMessage(event);
                list.add(new LogEntry(event.getName(), logEntryMessage));
            }

            return list;
        }
        catch (ClassNotFoundException e) {
            handler.onError(new Throwable(e), file);
            return null;
        }
        catch (IOException e) {
            handler.onError(new Throwable(e), file);
            return null;
        }
    }
1127412
public boolean sendResourceFile(HttpServletRequest request, HttpServletResponse response) throws IOException
    {
        String path = request.getPathInfo();
        if (path == null)
            path = request.getRequestURI();
        if (path == null)
            return false;
        path = this.fixPathInfo(path);
        
        return this.sendResourceFile(path, response);
    }
43822
public static void sendFileToHttpServiceResponse(File file, HttpServletResponse res, String contentType) {

        if (file == null || res == null) {
            return;
        }
        String filename = getEncodingFileName(file.getName());
        initFileSendHeader(res, filename, contentType);

        res.setContentLength((int) file.length());
        try {
            res.getOutputStream().write(Files.readAllBytes(file.toPath()));
        } catch (IOException e) {
            throw new ValidationLibException("file io error :" + e.getMessage());
        }
    }
515172
function writeFile (file, callback) {
  fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
    if (err) callback(err);
    callback(null);
  });
}
42907
public static void serialize(Object object, String file) throws Exception {
        if (object instanceof Serializable) {
            try (FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out =
                    new ObjectOutputStream(fileOut)) {
                out.writeObject(object);
            }
        } else {
            throw new Exception(object.getClass().getName() + " doesn't implements serializable interface");
        }
    }
753489
public SendDocument setDocument(File file) {
        Objects.requireNonNull(file, "documentName cannot be null!");
        this.document = new InputFile(file, file.getName());
        return this;
    }
370558
function sendfile(res, file, options, callback) {
  var done = false;
  var streaming;

  // request aborted
  function onaborted() {
    if (done) return;
    done = true;

    var err = new Error('Request aborted');
    err.code = 'ECONNABORTED';
    callback(err);
  }

  // directory
  function ondirectory() {
    if (done) return;
    done = true;

    var err = new Error('EISDIR, read');
    err.code = 'EISDIR';
    callback(err);
  }

  // errors
  function onerror(err) {
    if (done) return;
    done = true;
    callback(err);
  }

  // ended
  function onend() {
    if (done) return;
    done = true;
    callback();
  }

  // file
  function onfile() {
    streaming = false;
  }

  // finished
  function onfinish(err) {
    if (err && err.code === 'ECONNRESET') return onaborted();
    if (err) return onerror(err);
    if (done) return;

    setImmediate(function () {
      if (streaming !== false && !done) {
        onaborted();
        return;
      }

      if (done) return;
      done = true;
      callback();
    });
  }

  // streaming
  function onstream() {
    streaming = true;
  }

  file.on('directory', ondirectory);
  file.on('end', onend);
  file.on('error', onerror);
  file.on('file', onfile);
  file.on('stream', onstream);
  onFinished(res, onfinish);

  if (options.headers) {
    // set headers on successful transfer
    file.on('headers', function headers(res) {
      var obj = options.headers;
      var keys = Object.keys(obj);

      for (var i = 0; i < keys.length; i++) {
        var k = keys[i];
        res.setHeader(k, obj[k]);
      }
    });
  }

  // pipe
  file.pipe(res);
}
765161
@Override
    public synchronized void write(final Event event) throws IOException
    {
        if (!acceptsEvents) {
            log.warn("Writer not ready, discarding event: {}", event);
            return;
        }

        delegate.write(event);
        uncommittedWriteCount++;

        commitIfNeeded();
    }
161951
public void doHttpFilePost(String url, HttpResponse result, Map<String, Object> headers, File file) {
        httpClient.post(url, result, headers, file);
    }
15767
def send_file(self, file):
        
        if self.logger:
            self.logger.debug("[ioc.extra.tornado.RouterHandler] send file %s" % file)

        self.send_file_header(file)

        fp = open(file, 'rb')
        self.write(fp.read())

        fp.close()
450693
public FileSender sendFile(String filePath, final Handler<AsyncResult<Void>> doneHandler) {
    final File file = new File(filePath);
    output.vertx().fileSystem().exists(file.getAbsolutePath(), new Handler<AsyncResult<Boolean>>() {
      @Override
      public void handle(AsyncResult<Boolean> result) {
        if (result.failed()) {
          new DefaultFutureResult<Void>(result.cause()).setHandler(doneHandler);
        } else if (!result.result()) {
          new DefaultFutureResult<Void>(new IOException("File not found.")).setHandler(doneHandler);
        } else {
          output.group("file", file.getName(), new Handler<OutputGroup>() {
            @Override
            public void handle(final OutputGroup group) {
              output.vertx().fileSystem().open(file.getAbsolutePath(), new Handler<AsyncResult<AsyncFile>>() {
                @Override
                public void handle(AsyncResult<AsyncFile> result) {
                  if (result.failed()) {
                    new DefaultFutureResult<Void>(result.cause()).setHandler(doneHandler);
                  } else {
                    doSendFile(result.result(), group, doneHandler);
                  }
                }
              });
            }
          });
        }
      }
    });
    return this;
  }
1189186
function uploadHandler (event) {
    const target = event.target;

    if (target.files && target.files[0]) {
      file = target.files[0];
      const reader = new FileReader();

      reader.addEventListener('load', loadHandler);

      reader.readAsDataURL(file);
    }
  }
673039
public static void write(byte[] bytes,File file) throws IOException {
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file));
        outputStream.write(bytes);
        outputStream.close();
    }