Package java.io

Examples of java.io.File.renameTo()


        log.debug("Writing message to temporary file " + tmpFile);
        OutputStream out = new FileOutputStream(tmpFile);
        out.write(message);
        out.close();
        log.debug("Moving " + tmpFile + " to " + requestFile);
        if (!tmpFile.renameTo(requestFile)) {
            throw new IOException("Unable to rename " + tmpFile + " to " + requestFile);
        }
        log.debug("Done.");
    }
}
View Full Code Here


                            new File(serviceName, PersistentService.PROPERTIES_NAME);
                        if (replace) {
                            backupFile =
                                new File(serviceName, PersistentService.PROPERTIES_NAME.concat("old"));
                            try {
                                if(!servicePropertiesFile.renameTo(backupFile)) {
                                    throw StandardException.newException(
                                     SQLState.UNABLE_TO_RENAME_FILE, servicePropertiesFile, backupFile);
                                }
                            } catch (SecurityException se) {
                                throw Monitor.exceptionStartingModule(se);
View Full Code Here

                            new File(serviceName, PersistentService.PROPERTIES_NAME);
                        if (replace) {
                            backupFile =
                                new File(serviceName, PersistentService.PROPERTIES_NAME.concat("old"));
                            try {
                                if(!servicePropertiesFile.renameTo(backupFile)) {
                                    throw StandardException.newException(
                                     SQLState.UNABLE_TO_RENAME_FILE, servicePropertiesFile, backupFile);
                                }
                            } catch (SecurityException se) {
                                throw Monitor.exceptionStartingModule(se);
View Full Code Here

                                              COPYTOLOCAL_PREFIX, true);
      if (!FileUtil.copy(srcFS, src, tmp, false, srcFS.getConf())) {
        throw new IOException("Failed to copy " + src + " to " + dst);
      }
     
      if (!tmp.renameTo(dst)) {
        throw new IOException("Failed to rename tmp file " + tmp +
                              " to local destination \"" + dst + "\".");
      }

      if (copyCrc) {
View Full Code Here

            String name = file.getName();
            int sep = name.lastIndexOf('.');
            if (sep != -1) {
                String ext = name.substring(sep + 1);
                if (ext.equals(LOG_EXTENSION)) {
                    file.renameTo(new File(root, name + ".1"));
                } else {
                    try {
                        int version = Integer.parseInt(ext);
                        String newName = name.substring(0, sep + 1) +
                                String.valueOf(version + 1);
View Full Code Here

                } else {
                    try {
                        int version = Integer.parseInt(ext);
                        String newName = name.substring(0, sep + 1) +
                                String.valueOf(version + 1);
                        file.renameTo(new File(newName));
                    } catch (NumberFormatException e) {
                        log.warn("Bogusly named journal file, skipped: " + file);
                    }
                }
            }
View Full Code Here

        } catch (IOException e) {
            if (fos != null) {
                fos.close();
            }
            indexFile.delete();
            backupFile.renameTo(indexFile);
            throw e;
        }
    }

    public File createNewConfigurationDir() {
View Full Code Here

          LogHelper.logDebug("Message: " + e.getMessage() + ", cause: " + e.getCause());
          return;
        }
      }
      // rename BanHammer.db to BanHammer.db.done, so we don't attempt to convert again
      banHammer.renameTo(new File(plugin.getDataFolder(), "BanHammer.db.done"));
     
      // all done, inform about successful conversion in the console
      LogHelper.logInfo("[CommandsEX] " + _("bansConversionDone", ""));
    }
   
View Full Code Here

    public boolean rename(final String oldName, final String newName) {
        logger.debug("Rename {} to {}", oldName, newName);
        final String oldPath = cleanPath(oldName);
        final String newPath = cleanPath(newName);
        final File old = new File(oldPath);
        final boolean result = old.renameTo(new File(newPath));
        if ( result ) {
            this.checkClassLoader(oldPath);
            this.checkClassLoader(newPath);
        }
        return result;
View Full Code Here

      }
      if (filesToPackage.size() == 1){
        File returnFile = filesToPackage.iterator().next();
        if (returnFile.getName().toLowerCase().endsWith(".zip")){
          logger.debug("Only 1 zip file...no need to process");
          returnFile.renameTo(zipArchive);
          return;
        }
      }
    byte[] buffer = new byte[1024 * 1024];
     
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.