Package java.io

Examples of java.io.File.renameTo()


      temp = File.createTempFile(file.getName(), ".tmp", file
          .getParentFile());
      write(file, temp, set, values);
      temp.setLastModified(file.lastModified());
      file.delete();
      temp.renameTo(file);
    } finally
    {

    }
  }
View Full Code Here


          .getParentFile());

      write(file, temp, set, values, filter, listener);
      temp.setLastModified(file.lastModified());
      file.delete();
      temp.renameTo(file);
    } catch (UnsupportedEncodingException e)
    {
      if (temp != null && temp.exists() && file.exists())
        temp.delete();
      throw e;
View Full Code Here

        // System.out.println("temp: " + temp.getAbsolutePath());
        if (!file.renameTo(temp))
          System.out.println("rename failed file->temp: "
              + temp.getAbsolutePath());
        if (!temp.renameTo(file2))
          System.out.println("rename failed temp->file2: "
              + temp.getAbsolutePath());
      } catch (Exception e)
      {
        System.out.println(e.getMessage());
View Full Code Here

    try {
      msg.writeDelimitedTo(outputStream);
      outputStream.getChannel().force(true);
      outputStream.close();
      closed = true;
      if(!tmp.renameTo(file)) {
        //Some platforms don't support moving over an existing file.
        //So:
        //log.meta -> log.meta.old
        //log.meta.tmp -> log.meta
        //delete log.meta.old
View Full Code Here

    public void archiveDirectory() {
        File output = new File(getTargetDirectory());
        if (output.exists() && output.isDirectory()) {
            // if the directory already exists and is a directory,
            // we just renamed to "archive.date"
            output.renameTo(new File("archive." + getDayString()));
        }
    }

    /**
     * return the day in YYYYMMDD format
View Full Code Here

            if (target.exists() && !target.delete())
            {
                throw new MojoExecutionException("Could not remove " + target);
            }
            if (!tmp.renameTo(target))
            {
                throw new MojoExecutionException("Could not rename " + tmp + " to " + target);
            }
        }
        finally
View Full Code Here

        ArrayList<File> failed = new ArrayList<File>();
        for (String dataDir : DatabaseDescriptor.getAllDataFileLocations())
        {
            File ksDir = new File(dataDir, oldKs);
            if (ksDir.exists())
                if (!ksDir.renameTo(new File(dataDir, newKs)))
                    failed.add(ksDir);
        }

        if (!failed.isEmpty())
            throw new IOException("One or more problems encountered while renaming " + StringUtils.join(failed, ","));
View Full Code Here

      LogLog.debug("deleting existing target file: " + target);
      target.delete();
    }

    File file = new File(from);
    file.renameTo(target);
    LogLog.debug(from +" -> "+ to);
  }

  /** Delete's the specified file if it exists */
  protected static void deleteFile(String fileName) {
View Full Code Here

                input.close();
                if (!dir.delete()) {
                    log.error("Unable to delete old plugin at " + dir.getAbsolutePath());
                    throw new IOException("Unable to delete old plugin at " + dir.getAbsolutePath());
                }
                if (!temp.renameTo(dir)) {
                    log.error("Unable to move new plugin " + temp.getAbsolutePath() + " to " + dir.getAbsolutePath());
                    throw new IOException(
                            "Unable to move new plugin " + temp.getAbsolutePath() + " to " + dir.getAbsolutePath());
                }
            } catch (Exception e) {
View Full Code Here

        if (nameFromClz != null) {
            result = nameFromClz;
        }

        // rename the exising wsdl file
        if (result.exists() && !result.renameTo(new File(result.getParent(), result.getName()))) {
            throw new ToolException(new Message("OUTFILE_EXISTS", LOG));
        }
        return result;
    }
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.