Encodes a temporary location under the temporary directory.

@param journal the UFS journal instance*
@return the location
189577
static URI encodeTemporaryCheckpointFileLocation(UfsJournal journal) {
    return URIUtils.appendPathOrDie(journal.getTmpDir(), UUID.randomUUID().toString());
  }
289601
def _write_temp(content, suffix):
    ''''''
    with NamedTemporaryFile(mode='w', suffix=suffix, delete=False) as out:
        out.write(content)
        return out.name
265217
@Override
    public XMLStreamLocation2 getLocation()
    {
        return new WstxInputLocation(null, // no parent
        		null, (String) null, // pub/sys ids not yet known
        		mWriter.getAbsOffset(),
        		mWriter.getRow(), mWriter.getColumn());
    }
902708
private String buildPosition(String journalName, Long position, Long timestamp) {
        StringBuilder masterBuilder = new StringBuilder();
        if (StringUtils.isNotEmpty(journalName) || position != null || timestamp != null) {
            masterBuilder.append('{');
            if (StringUtils.isNotEmpty(journalName)) {
                masterBuilder.append("\"journalName\":\"").append(journalName).append("\"");
            }

            if (position != null) {
                if (masterBuilder.length() > 1) {
                    masterBuilder.append(",");
                }
                masterBuilder.append("\"position\":").append(position);
            }

            if (timestamp != null) {
                if (masterBuilder.length() > 1) {
                    masterBuilder.append(",");
                }
                masterBuilder.append("\"timestamp\":").append(timestamp);
            }
            masterBuilder.append('}');
            return masterBuilder.toString();
        } else {
            return null;
        }
    }
571337
public static String resourceFileToString(final String location, final String fileName) {
        if (location == null || fileName == null) return null;

        final InputStream in = ResourceUtilities.class.getResourceAsStream(location + fileName);
        if (in == null) return null;

        final BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String line;
        final StringBuilder output = new StringBuilder("");
        try {
            while ((line = br.readLine()) != null) {
                output.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                LOG.error("Failed to close the InputStream", e);
            }
            try {
                br.close();
            } catch (IOException e) {
                LOG.error("Failed to close the BufferedReader", e);
            }
        }
        return output.toString();
    }
1091091
public String encode() throws IOException {
        FastStringWriter fsw = new FastStringWriter();
        boolean hasComma = false;
        String preString;

        try {
            if (this.point != null) {
                fsw.write("\"point\":{");
                fsw.write(this.point.encode());
                fsw.write("}");

                hasComma = true;
            }

            if (this.line != null) {
                preString = hasComma ? "," : "";
                fsw.write(preString + "\"line\":{");
                fsw.write(this.line.encode());
                fsw.write("}");

                hasComma = true;
            }

            if (this.rectangle != null) {
                preString = hasComma ? "," : "";
                fsw.write(preString + "\"rectangle\":{");
                fsw.write(this.rectangle.encode());
                fsw.write("}");

                hasComma = true;
            }

            if (this.arc != null) {
                preString = hasComma ? "," : "";
                fsw.write(preString + "\"arc\":{");
                fsw.write(this.arc.encode());
                fsw.write("}");
            }
        }
        finally {
            fsw.close();
        }

        return fsw.toString();
    }
897688
public static File writeToTempFile(ByteBuffer byteBuffer, String prefix, String suffix) throws IOException {
        File tmpOutputFile = null;

        try (RandomAccessFile outputRaf = new RandomAccessFile(tmpOutputFile, "rw")) {
            // Create temporary file
            tmpOutputFile = File.createTempFile(prefix, "." + suffix);
            FileChannel outputChannel = outputRaf.getChannel();

            outputChannel.write(byteBuffer);

        } catch (IOException ioe) {
            String info = "Failed to write to temporary file: " + ioe.getMessage();
            throw new IOException(info, ioe);
        }
        return tmpOutputFile;
    }
988032
static UfsJournalFile createLogFile(URI location, long start, long end) {
    return new UfsJournalFile(location, start, end, false);
  }
353477
public JournalBuilder setArchived(File to) {
        if (!to.exists()) {
            throw new IllegalArgumentException("<" + to + "> does not exist");
        }
        if (!to.isDirectory()) {
            throw new IllegalArgumentException("<" + to + "> is not a directory");
        }
        this.directoryArchive = to;
        return this;
    }
210733
public File write(File destination) throws IOException {
		assertValid();
		
		if (destination.isDirectory() == true) {
			destination = new File(destination, this.header.getFileName());
		}
		if (data != null) {
			FileUtil.writeBytes(data, destination);
			data = null;
		} else {
			if (tempFile != null) {
				FileUtil.move(tempFile, destination, true);
			}
		}
		return destination;
	}
708343
public static String getJournalReport(QJMStatus status) {
    StringBuilder sb = new StringBuilder();
    sb.append("<table border=1 cellpadding=1 cellspacing=0 title=\"Journals\">");
    sb.append("<thead><tr><td><b>JournalId</b></td><td><b>Statistics</b></td></tr></thead>");
    for (String journalId : status.getJournalIds()) {
      sb.append("<tr><td>" + journalId + "</td><td>");
      getHTMLTableForASingleJournal(status, journalId, sb);
      sb.append("</td></tr>");
    }
    sb.append("</table>");
    return sb.toString();
  }
1358010
public static File writeToTempFile(List<byte[]> bytesList, String prefix, String suffix) throws IOException {
        File tmpOutputFile = null;

        try (RandomAccessFile outputRaf = new RandomAccessFile(tmpOutputFile, "rw")) {
            // Create temporary file
            tmpOutputFile = File.createTempFile(prefix, "." + suffix);
            FileChannel outputChannel = outputRaf.getChannel();

            for (byte[] bytes : bytesList) {
                ByteArrayInputStream is = null;
                try {
                    is = new ByteArrayInputStream(bytes);
                    ReadableByteChannel inputChannel = Channels.newChannel(is);
                    fastChannelCopy(inputChannel, outputChannel);
                } catch (Exception e) {
                    String info = "Failed to write to temporary file: " + e.getMessage();
                    throw new IOException(info, e);
                } finally {
                    if (null != is) is.close();
                }
            }
        } catch (IOException ioe) {
            String info = "Failed to write to temporary file: " + ioe.getMessage();
            throw new IOException(info, ioe);
        }
        return tmpOutputFile;
    }
631052
public synchronized void updateDeployMode(DeployMode mode) {
    mDeployMode = mode;
    if (mDeployMode == DeployMode.EMBEDDED) {
      // Ensure that the journal properties are set correctly.
      for (int i = 0; i < mMasters.size(); i++) {
        Master master = mMasters.get(i);
        MasterNetAddress address = mMasterAddresses.get(i);
        master.updateConf(PropertyKey.MASTER_EMBEDDED_JOURNAL_PORT,
            Integer.toString(address.getEmbeddedJournalPort()));

        File journalDir = new File(mWorkDir, "journal" + i);
        journalDir.mkdirs();
        master.updateConf(PropertyKey.MASTER_JOURNAL_FOLDER, journalDir.getAbsolutePath());
      }
    }
  }
1248147
private static File getFax4jInternalTemporaryDirectoryImpl()
    {
        File temporaryFile=null;
        try
        {
            //create temporary file
            temporaryFile=File.createTempFile("temp_",".temp");
        }
        catch(IOException exception)
        {
            throw new FaxException("Unable to create temporary file.",exception);
        }
        
        //get parent directory
        File temporaryDirectory=temporaryFile.getParentFile();
        
        //delete file
        boolean deleted=temporaryFile.delete();
        if(!deleted)
        {
            temporaryFile.deleteOnExit();
        }

        //read properties
        Properties properties=LibraryConfigurationLoader.readInternalConfiguration();

        //get values
        String name=properties.getProperty("org.fax4j.product.name");
        String version=properties.getProperty("org.fax4j.product.version");

        //create sub directory
        File fax4jTemporaryDirectory=new File(temporaryDirectory,name+"_"+version);
        if(!fax4jTemporaryDirectory.exists())
        {
            boolean created=fax4jTemporaryDirectory.mkdirs();
            if(!created)
            {
                throw new FaxException("Unable to create fax4j internal temporary directory: "+fax4jTemporaryDirectory);
            }
        }

        return fax4jTemporaryDirectory;
    }
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;
    }
100727
@Override
    public void writeJournalEntry(CreatorJournalEntry journalEntry)
            throws JournalException {
        try {
            super.writeJournalEntry(journalEntry, writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new JournalException(e);
        }
    }
649647
public synchronized File getTempDirectory() throws IOException {
        if (tempDirectory == null) {
            final File baseTemp = new File(getString(Settings.KEYS.TEMP_DIRECTORY, System.getProperty("java.io.tmpdir")));
            tempDirectory = FileUtils.createTempDirectory(baseTemp);
        }
        return tempDirectory;
    }