/** * Caller must synchronize * * @since 0.9.1 */ private void createTemp() throws IOException { //tfile = SecureFile.createTempFile("piece", null, tempDir); // debug tempfile = SecureFile.createTempFile("piece_" + piece.getId() + '_', null, tempDir); //I2PAppContext.getGlobalContext().logManager().getLog(PartialPiece.class).warn("Created " + tempfile); // tfile.deleteOnExit() ??? raf = new RandomAccessFile(tempfile, "rw"); // Do not preallocate the file space. // Not necessary to call setLength(), file is extended when written //traf.setLength(len); }
return false; in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024); File tmp = SecureFile.createTempFile("temp-", ".tmp", _file.getAbsoluteFile().getParentFile()); out = new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8")); String line = null;
/** * Write contents of Map map to the File file. Output is written * with one key, value pair on each line, in the format: key=value. * Write to a temp file in the same directory and then rename, to not corrupt * simultaneous accesses by the router. Except on Windows where renameTo() * will fail if the target exists. * * @param map * A Map to write to file. * @param file * A File to write the Map to. * @throws IOException * if file cannot be written to. */ public static void write(Map<String, HostTxtEntry> map, File file) throws IOException { boolean success = false; if (!isWindows) { File tmp = SecureFile.createTempFile("temp-", ".tmp", file.getAbsoluteFile().getParentFile()); write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8"))); success = tmp.renameTo(file); if (!success) { tmp.delete(); //System.out.println("Warning: addressbook rename fail from " + tmp + " to " + file); } } if (!success) { // hmm, that didn't work, try it the old way write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8"))); } }
if (_isClosed) return false; File tmp = SecureFile.createTempFile("temp-", ".tmp", _file.getAbsoluteFile().getParentFile()); out = new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8")); if (_file.exists()) {
/** * Write contents of Map map to the File file. Output is written * with one key, value pair on each line, in the format: key=value. * Write to a temp file in the same directory and then rename, to not corrupt * simultaneous accesses by the router. Except on Windows where renameTo() * will fail if the target exists. * * @param map * A Map to write to file. * @param file * A File to write the Map to. * @throws IOException * if file cannot be written to. */ public static void write(Map<String, String> map, File file) throws IOException { boolean success = false; if (!isWindows) { File tmp = SecureFile.createTempFile("temp-", ".tmp", file.getAbsoluteFile().getParentFile()); write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8"))); success = tmp.renameTo(file); if (!success) { tmp.delete(); //System.out.println("Warning: addressbook rename fail from " + tmp + " to " + file); } } if (!success) { // hmm, that didn't work, try it the old way write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8"))); } }
try { out = SecureFile.createTempFile("i2psnark", null, _tmpDir); } catch (IOException ioe) { _log.error("temp file error", ioe);
File tmp = null; try { tmp = SecureFile.createTempFile("addressbook", null, I2PAppContext.getGlobalContext().getTempDir()); EepGet get = new EepGet(I2PAppContext.getGlobalContext(), true, proxyHost, proxyPort, 0, -1l, MAX_SUB_SIZE, tmp.getAbsolutePath(), null,
File out = null; try { out = SecureFile.createTempFile("torrentFile", null, _mgr.util().getTempDir()); } catch (IOException ioe) { _log.error("temp file error", ioe);