Creates a new writable temporary file that is deleted when closed,
finalized, or when the system exits.

@see File#createTempFile
544471
public static RandomAccessFile createTemporaryFile
        (String prefix, String suffix) throws IOException {

        return createTemporaryFile(prefix, suffix, null);
    }
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) {
        }
      }
    }
  }
281607
def _CreateTempDir(prefix, run_dir=None):
  
  temp_dir = tempfile.mkdtemp(prefix=prefix + '-', dir=run_dir)
  try:
    yield temp_dir
  finally:
    shutil.rmtree(temp_dir)
130784
private File createTmpFile(final String path) throws IOException {
        getLog().debug("Creating temporary file for: " + path);
        final File output = new File(System.getProperty("java.io.tmpdir"), "ansible-maven-plugin." + System.nanoTime());
        final FileOutputStream outputStream = new FileOutputStream(output);
        final InputStream inputStream = getClass().getResourceAsStream("/" + path);
        if (inputStream == null){
            throw new FileNotFoundException("Unable to locate: " + path);
        }
        copy(inputStream, outputStream);
        return output;
    }
920657
public Writer open() throws IOException {
        switch (state) {
            case OPEN:
                throw new IllegalStateException("File " + tempFile
                        + " is already open.");
            case CLOSED:
                throw new IllegalStateException("File " + tempFile
                        + " has been closed already.");
            default: // READY
                state = State.OPEN;
                tempFile.createNewFile();
                fileWriter = new FileWriter(tempFile);
                return fileWriter;
        }
    }
870902
private File baseDir() throws IOException {
        if (baseDir == null) {
            baseDir = File.createTempFile("fcrepo-dto", null);
            if (!baseDir.delete()) {
                throw new IOException("Can't delete temp file " + baseDir);
            }
            if (!baseDir.mkdir()) {
                throw new IOException("Can't create temp dir " + baseDir);
            }
        }
        return baseDir;
    }
278504
public static File createTempFile(final String prefix, final String suffix)
	{
		try
		{
			File tempFile = File.createTempFile(prefix, suffix);
			if (tempFile.exists())
			{
				if (!tempFile.delete())
					throw new RuntimeException("Could not delete new temp file: " + tempFile);
			}

			return tempFile;
		}
		catch (IOException e)
		{
			log.error("[FileHelper] {createTempFile} Error creating temp file: " + e.getMessage(), e);
			return null;
		}
	}
745167
@Deprecated
    public static File createTempDirectory( final String    prefix )
        throws
            IOException
    {
        File tempDir;

        tempDir = File.createTempFile( prefix, null );

        if( ! ( tempDir.delete() ) )
        {
            throw new IOException( "Could not delete temp file: " + tempDir.getAbsolutePath() );
        }

        if( ! ( tempDir.mkdir() ) )
        {
            throw new IOException( "Could not create temp directory: " + tempDir.getAbsolutePath() );
        }

        return tempDir;
    }
1325110
protected String createTempFile() throws CmsException {

        return OpenCms.getWorkplaceManager().createTempFile(getCms(), getParamResource(), getSettings().getProject());
    }
716252
private void writeToTempFile(int at_offset, byte[] data, int offset, int len) throws IOException {
        if (_tempfile == null) {
            createTempFile();
            _file_pos = -1;
        }
        _file_mode = true;
        if (at_offset != _file_pos) {
            _tempfile.seek((long)at_offset);
        }
        _tempfile.write(data,offset,len);
        _file_pos = at_offset + len;
        _file_high = max(_file_high,_file_pos);
    }
1255364
@Override
	public FSDataOutputStream create(Path f, WriteMode overwriteMode) throws IOException {
		return createOutputStream(() -> originalFs.create(f, overwriteMode));
	}
999314
def with_temporary_files(file_contents='', dest_extension = '', source_extension = '', message=nil)

      #File mode for all of the created temporary files.
      #Create the files, and allow read/write, but do not lock for exclusive access.
      file_mode = File::CREAT | File::RDWR

      #Create a new file which contains the provided file content.
      #Used to pass arbitrary data into an external tool.
      Tempfile.open(['core_prev', source_extension], :mode => file_mode) do |source_file|

        #Fill the source file with the provided file contents...
        source_file.write(file_contents)
        source_file.flush

        #Create a new file which will store the resultant file content.
        Tempfile.open(['core_next', dest_extension], :mode => file_mode) do |destination_file|

          #Yield the file's paths the provided block.
          raise CommandFailedError, message unless yield [destination_file.path, source_file.path]

          #And return the content of the destination file.
          return File::read(destination_file)

        end

      end
    end
1117893
public static FileChannel createTempFile(Path dir, String prefix, String suffix) throws IOException {
        return createNewFileImpl(dir, prefix, suffix, new OpenOption[]{READ, WRITE, CREATE_NEW, DELETE_ON_CLOSE}).getFileChannel();
    }
1231019
private static File createTempFile(File storageDir) throws IOException {
        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";
        if(!storageDir.mkdir() && !storageDir.exists()){
            throw new IOException("Unable to create temporary media directory");
        }

        return File.createTempFile(
                imageFileName,  /* prefix */
                ".jpg",         /* suffix */
                storageDir      /* directory */
        );
    }
1315117
public static final Path createTemporaryVolume(String password) {
        final File tmpFile = new File("target/vnc/.tmp" + System.currentTimeMillis());

        if (!tmpFile.mkdirs()) {
            throw new IllegalArgumentException("Temporary Folder for storing recordings could not be created.");
        }

        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                FileUtils.deleteQuietly(tmpFile);
            }
        });

        final Path temp = tmpFile.toPath();
        Path passwordFile = temp.resolve("password");

        try {
            Files.write(passwordFile, password.getBytes());
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }

        return temp;
    }
984518
public static File createTempFile(Context c, File root, String filename, String extension){
        File output = null;
        try {
            if(filename != null){
                if(!extension.contains("."))
                    extension = "." + extension;
                output = new File(root, filename + extension);
                output.createNewFile();
                //output = File.createTempFile(filename, extension, root);
                Log.i(TAG, "Created temp file: " + output.getAbsolutePath());
            }
            return output;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
675599
void checkWritableDir(String tempPath) {
    try {
      File tempFile = File.createTempFile("check", "tmp", new File(tempPath));
      deleteQuietly(tempFile);
    } catch (IOException e) {
      throw new IllegalStateException(format("Temp directory is not writable: %s", tempPath), e);
    }
  }