Package java.io

Examples of java.io.File.renameTo()


        final File f1 = new File(targetDir, OAIPMHImporter.filename4Source(source));
        final File f0 = new File(targetDir, f1.getName() + ".tmp");

        // transaction-safe writing
        FileUtils.copy(b, f0);
        f0.renameTo(f1);

        /*
        SurrogateReader sr = new SurrogateReader(new ByteArrayInputStream(b), 100);
        Thread srt = new Thread(sr);
        srt.start();
View Full Code Here


            out.close();
            zf.close();
            if (!f.delete()) {
                throw new IOException("Cannot delete file " + f);
            }
            if (!g.renameTo(f)) {
                throw new IOException("Cannot rename file " + g);
            }
        }
    }
View Full Code Here

               if (f.length() == 0) {
                   f.delete();
                   deletions = true;
               } else try {
                   d = GenericFormatter.SHORT_SECOND_FORMATTER.parse(files[i].substring(0, 14));
                   f.renameTo(newBLOB(d));
                   deletions = true;
               } catch (ParseException e) {continue;}
            }
        }
        if (deletions) files = heapLocation.list(); // make a fresh list
View Full Code Here

            os.write(i.next().bytes());
            c++;
        }
        os.flush();
        os.close();
        tmp.renameTo(file);
        assert file.exists() : file.toString();
        assert !tmp.exists() : tmp.toString();
        return c;
    }
View Full Code Here

            os.writeInt(e.getValue().intValue());
            c++;
        }
        os.flush();
        os.close();
        tmp.renameTo(file);
        assert file.exists() : file.toString();
        assert !tmp.exists() : tmp.toString();
       
        return c;
    }
View Full Code Here

            if ((tablefile[i].startsWith(prefix)) &&
                (tablefile[i].charAt(prefix.length()) == '.') &&
                (tablefile[i].length() == prefix.length() + 7)) {
                f = new File(path, tablefile[i]);
                String newname = tablefile[i] + "0100000" + (Long.toString(r.nextLong())+"00000").substring(1,5) + ".table";
                f.renameTo(new File(path, newname));
            }
        }
        // read new list again
        tablefile = path.list();
       
View Full Code Here

    HeaderInfoWriter writer = new HeaderInfoWriter(info);
    try {
      String spool = file + ".spool";
      writer.write(spool);
      File f = new File(spool);
      if (f.renameTo(new File(file))) {
        info.setModified(false);
      }
      return true;
    } catch (IOException e) {
      JOptionPane.showMessageDialog(null,"Error writing " + file +" " + e, "Save Error", JOptionPane.ERROR_MESSAGE);
View Full Code Here

    CdtWriter writer = new CdtWriter(dataModel);
    try {
      String spool = file + ".spool";
      writer.write(spool);
      File f = new File(spool);
      if (f.renameTo(new File(file))) {
        dataModel.getDataMatrix().setModified(false);
        dataModel.getArrayHeaderInfo().setModified(false);
        dataModel.getGeneHeaderInfo().setModified(false);
      }
      return true;
View Full Code Here

      fos.write((header_+System.getProperty("line.separator")).getBytes(StringHelper.check4xMacRoman(charSet)));
      FileUtils.copy(fis, fos);
      fis.close();
      fos.close();
      outFile.delete();
      tmpOutFile.renameTo(outFile);
     
      log_.info("exportCourseLog: resulting outfile="+outFile.getAbsolutePath());
    } catch(RuntimeException e) {
      String details = "outFile="+outFile.getAbsolutePath()+", resAdminAction="+resourceAdminAction+", resourceableId="+resourceableId+", anonymize="+anonymize+", begin="+(begin==null ? null : begin.getTime())+", end="+(end==null ? null : end.getTime());
      log_.error("exportCourseLog: runtime exception. Details: "+details,e);
View Full Code Here

     * operation.
     */
    private boolean renameWithOverwrite(String oldname, String newname) {

        File    file    = new File(oldname);
        boolean renamed = file.renameTo(new File(newname));

        if (renamed) {
            return true;
        }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.