Writes from an InputStream to a temporary file
510164
public static File writeToTempFile(InputStream inputStream, String prefix, String suffix) throws IOException {

        File file = File.createTempFile(prefix, "." + suffix);
        writeToFile(inputStream, file);
        return file;
    }
196654
public static int write(InputStream is, OutputStream os, boolean closeSink) {
        return copy(is, os, closeSink);
    }
58590
public void writeToFile(String path) {
        try {
            try (OutputStream os = new FileOutputStream(path)) {
                InputStreams.transferTo(body(), os);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
1295596
public void writeTo(OutputStream target) throws IOException {
        this.data.close();
        BufferedInputStream tempIn = new BufferedInputStream(new FileInputStream(this.tempFile));
        byte[] buffer = new byte[8192];
        int bytesRead = -1;
        while((bytesRead = tempIn.read(buffer)) >= 0) {
            target.write(buffer, 0, bytesRead);
        }
        tempIn.close();
        this.tempFile.delete();
    }
1277023
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    if (! _isPost) {
      return;
    }

    if (_tempStream == null) {
      _tempStream = new MemoryStream();
    }

    _tempStream.write(buf, offset, length, isEnd);
  }
1077549
def write_temp_file(content):
        
        f_temp = NamedTemporaryFile(delete=True)
        f_temp.file.write(content)
        f_temp.file.flush()
        return f_temp
454638
public static void decompressChunks(InputStream inputStream, Path tempFileOut) throws IOException {
        try (BufferedWriter writer = Files.newBufferedWriter(tempFileOut)) {
            try (GZIPInputStream chunkZipper = new GZIPInputStream(inputStream);
                 InputStream in = new BufferedInputStream(chunkZipper);) {
                byte[] buffer = new byte[BYTES_BUFFER_SIZE];
                int len;
                while ((len = in.read(buffer)) > 0) {
                    byte[] writtenBytes = new byte[len];
                    getBytes(buffer, 0, len, writtenBytes, 0);
                    String val = new String(writtenBytes, StandardCharsets.UTF_8);
                    writer.write(val);
                }
            }
        }
    }
77874
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
    FileOutputStream fos = null;
    try {
      File tmpFile;
      if (tmpDirFile == null) {
    	  tmpFile = File.createTempFile(name, '.' + ext);
      } else {
        tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile);
      }
      tmpFile.deleteOnExit();
      fos = new FileOutputStream(tmpFile);
      int read = 0;
      byte[] bytes = new byte[1024 * 100];
      while ((read = inputStream.read(bytes)) != -1) {
        fos.write(bytes, 0, read);
      }
      fos.flush();
      return tmpFile;
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
        }
      }
      if (fos != null) {
        try {
          fos.close();
        } catch (IOException e) {
        }
      }
    }
  }
548497
function write(filename, mtime, data) {
  var tempname = filename + '+';

  try {
    mkdirp(path.dirname(filename));
    fs.writeFileSync(tempname, toBuffer(data));
    fs.renameSync(tempname, filename);
    fs.utimesSync(filename, mtime, mtime);
  } catch (err) {
    // Try to remove tmp file on error.
    // Don't check if exists, just suppress errors
    try { fs.unlinkSync(tempname); } catch (__) {}

    throw err;
  }
}
1177355
public static void write(final InputStream inputStream, final OutputStream outputStream)
		throws FileNotFoundException, IOException
	{
		int counter;
		final byte byteArray[] = new byte[FileConst.BLOCKSIZE];
		while ((counter = inputStream.read(byteArray)) != -1)
		{
			outputStream.write(byteArray, 0, counter);
		}
	}
960134
@Override
    public void writeByteStream(InputStream is)
        throws IOException
    {
        while (true) {
            int len = SIZE - _offset - 3;

            if (len < 16) {
                flushBuffer();
                len = SIZE - _offset - 3;
            }

            len = is.read(_buffer, _offset + 3, len);

            if (len <= 0) {
                _buffer[_offset++] = BC_BINARY_DIRECT;
                return;
            }

            _buffer[_offset + 0] = (byte) BC_BINARY_CHUNK;
            _buffer[_offset + 1] = (byte) (len >> 8);
            _buffer[_offset + 2] = (byte) (len);

            _offset += len + 3;
        }
    }
5957
public File writeFromStream(InputStream in) throws IORuntimeException {
		FileOutputStream out = null;
		try {
			out = new FileOutputStream(FileUtil.touch(file));
			IoUtil.copy(in, out);
		}catch (IOException e) {
			throw new IORuntimeException(e);
		} finally {
			IoUtil.close(out);
		}
		return file;
	}
49164
public static File writeZipStreamToTempDir(InputStream inputStream) throws IOException
   {
      File dir = FileHelper.createTempDir();

      try
      {
         processZipStream(dir, inputStream);
      }

      catch (ZipException ex)
      {
         // Java doesn't support zip files with zero byte entries.
         // We could use a different library which does handle these zip files, but
         // I'm reluctant to add new dependencies just for this. Rather than
         // propagating the error, we'll just stop at this point and see if we
         // can make sense of anything we have extracted from the zip file so far.
         // For what it's worth I haven't come across a valid compressed schedule file
         // which includes zero bytes files.
         if (!ex.getMessage().equals("only DEFLATED entries can have EXT descriptor"))
         {
            throw ex;
         }
      }

      return dir;
   }
787661
public void write(Object from, File target) throws IOException {
    OutputStream outputStream = new FileOutputStream(target);
    try {
      write(from, outputStream);
    } finally {
      outputStream.close();
    }
  }
508133
def _CopyFileObjectToTemporaryFile(self, file_object, temporary_file):
    
    file_object.seek(0, os.SEEK_SET)
    data = file_object.read(self._READ_BUFFER_SIZE)
    while data:
      temporary_file.write(data)
      data = file_object.read(self._READ_BUFFER_SIZE)
77663
private static void writeStream(
            final InputStream input,
            final FileWriter writer,
            final LineEndingStyle style
    ) throws IOException
    {
        try (InputStreamReader inStream = new InputStreamReader(input)) {
            writeReader(inStream, writer, style);
        }
    }
98085
private InputStream dumpInputStream(InputStream is) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        InputStream copiedStream = null;
        try {

            byte buf[] = new byte[2048];
            int len;
            while ((len = is.read(buf)) > 0) {
                baos.write(buf, 0, len);
            }
            byte[] streamBytes = baos.toByteArray();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, " InputStream dump ", baos.toString());
            }

            copiedStream = new ByteArrayInputStream(streamBytes);

            is.close();
        } catch (IOException e) {
            // an IOException here will mean that we screwed up the original stream
            // we'll need to return null and the caller will need to attempt to
            // re-obtain the stream
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, " InputStream dump failed ", e);
            }
            FFDCFilter.processException(e, CLASS_NAME + ".dumpInputStream", "630");

        } finally {
            try {
                baos.close();
            } catch (IOException e) {
                //AutoFFDC
            }
        }
        return copiedStream;

    }