com.metsci.glimpse.util.jnlu
Class FileUtils

java.lang.Object
  extended by com.metsci.glimpse.util.jnlu.FileUtils

public class FileUtils
extends java.lang.Object

Author:
hogye

Nested Class Summary
static class FileUtils.DeleteRecursively
           
 
Constructor Summary
FileUtils()
           
 
Method Summary
static void copy(java.net.URL fromUrl, java.io.File toFile)
           
static java.io.File createTempDir(java.lang.String prefix)
           
static boolean deleteRecursively(java.io.File fileOrDir)
           
static void execDeleteRecursively(int numAttempts, int millisBetweenAttempts, java.io.File fileOrDir)
          Spawns a separate process that will delete the specified file or directory.
static void scheduleRecursiveDeleteAfterShutdown(java.io.File fileOrDir)
          On some platforms, a file cannot be deleted while it is in use.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

createTempDir

public static java.io.File createTempDir(java.lang.String prefix)
                                  throws java.io.IOException
Throws:
java.io.IOException

scheduleRecursiveDeleteAfterShutdown

public static void scheduleRecursiveDeleteAfterShutdown(java.io.File fileOrDir)
On some platforms, a file cannot be deleted while it is in use. In some cases, certain files may be in use by the JVM until it exits, and therefore can only be deleted after the JVM exits. Notably, this includes native library files. This method registers a shutdown hook that will spawn a separate JVM, from which repeated attempts will be made to delete the specified file or directory. These attempts will continue for up to 30 seconds, which should be enough time for this JVM to exit, at which point any files it had open can be deleted.


execDeleteRecursively

public static void execDeleteRecursively(int numAttempts,
                                         int millisBetweenAttempts,
                                         java.io.File fileOrDir)
                                  throws java.io.IOException
Spawns a separate process that will delete the specified file or directory. The process attempts the deletion repeatedly, until it succeeds, up to numAttempts times.

Throws:
java.io.IOException

deleteRecursively

public static boolean deleteRecursively(java.io.File fileOrDir)

copy

public static void copy(java.net.URL fromUrl,
                        java.io.File toFile)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2012 Metron, Inc.. All Rights Reserved.