org.apache.logging.log4j.core.util
Class FileUtils

java.lang.Object
  extended by org.apache.logging.log4j.core.util.FileUtils

public final class FileUtils
extends Object

File utilities.


Method Summary
static File fileFromUri(URI uri)
          Tries to convert the specified URI to a file object.
static URI getCorrectedFilePathUri(String uri)
          Takes a given URI string which may contain backslashes (illegal in URIs) in it due to user input or variable substitution and returns a URI with the backslashes replaced with forward slashes.
static boolean isFile(URL url)
           
static void mkdir(File dir, boolean createDirectoryIfNotExisting)
          Asserts that the given directory exists and creates it if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fileFromUri

public static File fileFromUri(URI uri)
Tries to convert the specified URI to a file object. If this fails, null is returned.

Parameters:
uri - the URI
Returns:
the resulting file object

isFile

public static boolean isFile(URL url)

mkdir

public static void mkdir(File dir,
                         boolean createDirectoryIfNotExisting)
                  throws IOException
Asserts that the given directory exists and creates it if necessary.

Parameters:
dir - the directory that shall exist
createDirectoryIfNotExisting - specifies if the directory shall be created if it does not exist.
Throws:
IOException - thrown if the directory could not be created.

getCorrectedFilePathUri

public static URI getCorrectedFilePathUri(String uri)
                                   throws URISyntaxException
Takes a given URI string which may contain backslashes (illegal in URIs) in it due to user input or variable substitution and returns a URI with the backslashes replaced with forward slashes.

Parameters:
uri - The URI string
Returns:
the URI.
Throws:
URISyntaxException - if instantiating the URI threw a URISyntaxException.


Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.