com.izforge.izpack.util
Class FileUtil

java.lang.Object
  extended by com.izforge.izpack.util.FileUtil

public class FileUtil
extends Object

Provides general global file utility methods

Author:
marc.eppelmann

Constructor Summary
FileUtil()
           
 
Method Summary
static File convertUrlToFile(URL url)
           
static String convertUrlToFilePath(URL url)
           
static File getAbsoluteFile(String filename, String basedir)
          Gets an absolute file from a filename.
static List<String> getFileContent(String fileName)
          Gets the content from a File as StringArray List.
static long getFileDateTime(URL url)
          Gets file date and time.
static String[] getFileNames(String dirPath, FilenameFilter fileNameFilter)
           
static File getLockFile(String applicationName)
           
static String getRelativeFileName(File file, File basedir)
          Gets a relative file from a filename against a base directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

convertUrlToFile

public static File convertUrlToFile(URL url)

convertUrlToFilePath

public static String convertUrlToFilePath(URL url)

getLockFile

public static File getLockFile(String applicationName)

getFileContent

public static List<String> getFileContent(String fileName)
                                   throws IOException
Gets the content from a File as StringArray List.

Parameters:
fileName - A file to read from.
Returns:
List of individual line of the specified file. List may be empty but not null.
Throws:
IOException

getFileDateTime

public static long getFileDateTime(URL url)
Gets file date and time.

Parameters:
url - The URL of the file for which date and time will be returned.
Returns:
Returns long value which is the date and time of the file. If any error occurs returns -1 (=no file date and time available).

getFileNames

public static String[] getFileNames(String dirPath,
                                    FilenameFilter fileNameFilter)

getAbsoluteFile

public static File getAbsoluteFile(String filename,
                                   String basedir)
Gets an absolute file from a filename. In difference to File.isAbsolute() this method bases relative file names on a given base directory.

Parameters:
filename - The filename to build an absolute file from
basedir - The base directory for a relative filename
Returns:
The absolute file according to the described algorithm

getRelativeFileName

public static String getRelativeFileName(File file,
                                         File basedir)
                                  throws IOException
Gets a relative file from a filename against a base directory. Enclosed '.' and '..' characters are resolved for all parameters.

Parameters:
file - The filename to build a relative file from
basedir - The base directory for a relative filename
Returns:
The relative file name, or null, if one input parameter was null
Throws:
IOException - if the file paths cannot be canonicalized


Copyright © 2017. All rights reserved.