| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xnap.commons.util.FileHelper
public class FileHelper
Provides a set of static methods that help with file manipulation.
| Constructor Summary | |
|---|---|
| FileHelper() | |
| Method Summary | |
|---|---|
| static String | appendSeparator(String path)Appens a file separator to pathif it does not have a
 trailing one. | 
| static void | copy(File source,
     File dest) | 
| static void | copy(File source,
     File dest,
     ProgressMonitor monitor)Copies sourcetodest. | 
| static void | copy(InputStream inStream,
     OutputStream outStream) | 
| static void | copy(InputStream inStream,
     OutputStream outStream,
     ProgressMonitor monitor)Copies sourcetodest. | 
| static File | createUnique(File parent,
             String child)Creates a unique file in by inserting digits into filename. | 
| static File | createUnique(String pathname)Creates a unique file by inserting digits into pathname. | 
| static boolean | exists(String pathname)Returns true, if the file denoting pathnameexists,
 false otherwise. | 
| static String | extension(String filename)Returns the lower case extension part of filename. | 
| static String | getHomeDir(String appname)Returns the absolute path of the applications settings directory. | 
| static String | getHomeDir(String appname,
           String subdir)Checks for existence of .xnap folder in the user's home directory and returns the absolute path with a file separator appended. | 
| static boolean | move(File source,
     File dest)Moves a file. | 
| static File | moveUnique(File file,
           String path)Moves filetopath. | 
| static File | moveUnique(File file,
           String path,
           String filename)Moves filetopathbut renamesfilenameif it already exists in the target path. | 
| static String | name(String filename)Returns the name part of filenamewithout 
 its extension. | 
| static void | readBinary(File file,
           Collection<Object> c)Reads all objects from fileusing serialization and adds 
 them toc. | 
| static String[] | readConfig(File file)TODO provide a symmetrical write function? | 
| static String[] | readConfig(InputStream inStream)Reads a text file. | 
| static String | readText(File file) | 
| static String | readText(InputStream inStream)Reads a text file. | 
| static void | shorten(File file,
        long bytes)Shortens filebybytesbytes. | 
| static String | uniqueName(String filename)Creates unique filename. | 
| static String | uniqueName(String filename,
           String infix) | 
| static void | writeBinary(File file,
            Collection c)Write all items in ctofileusing 
 serialization. | 
| static void | writeProperties(File file,
                Properties props)Stores propsinfile. | 
| static void | writeText(File file,
          String text)Writes a text file. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public FileHelper()
| Method Detail | 
|---|
public static File createUnique(String pathname)
                         throws IOException
pathname.
IOException
public static File createUnique(File parent,
                                String child)
                         throws IOException
filename.
child - the name of the file to createparent - the path of the file to create
IOException
public static File moveUnique(File file,
                              String path,
                              String filename)
                       throws IOException
file to path but renames 
 filename if it already exists in the target path.
file - the file to movepath - the target pathfilename - the new filename for file
IOException
public static File moveUnique(File file,
                              String path)
                       throws IOException
file to path.
IOExceptionmoveUnique(File, String, String)
public static boolean move(File source,
                           File dest)
                    throws IOException
IOException
public static void copy(File source,
                        File dest)
                 throws IOException
IOException
public static void copy(File source,
                        File dest,
                        ProgressMonitor monitor)
                 throws IOException
source to dest. If dest already exists
 it is overwritten.
source - the source filedest - the destination file
IOException
public static void copy(InputStream inStream,
                        OutputStream outStream)
                 throws IOException
IOException
public static void copy(InputStream inStream,
                        OutputStream outStream,
                        ProgressMonitor monitor)
                 throws IOException
source to dest. If dest already exists
 it is overwritten.
inStream - the source dataoutStream - the destination data
IOExceptionpublic static String extension(String filename)
filename.
name(String)public static String name(String filename)
filename without 
 its extension.
extension(String)public static String uniqueName(String filename)
public static String uniqueName(String filename,
                                String infix)
public static boolean exists(String pathname)
pathname exists,
 false otherwise.
public static final String getHomeDir(String appname,
                                      String subdir)
                               throws IOException
subdir - a sub directory that is located in the applications settings directory or created if
 it does not exist
IOException
public static final String getHomeDir(String appname)
                               throws IOException
IOExceptiongetHomeDir(String)public static String appendSeparator(String path)
path if it does not have a
 trailing one.
public static void shorten(File file,
                           long bytes)
                    throws IOException
file by bytes bytes.
IOException
public static void writeProperties(File file,
                                   Properties props)
                            throws IOException
props in file.
IOException
public static void readBinary(File file,
                              Collection<Object> c)
                       throws IOException
file using serialization and adds 
 them to c.
IOException
public static String readText(File file)
                       throws IOException
IOException
public static String readText(InputStream inStream)
                       throws IOException
IOException
public static String[] readConfig(File file)
                           throws IOException
file - 
IOException
public static String[] readConfig(InputStream inStream)
                           throws IOException
IOException
public static void writeBinary(File file,
                               Collection c)
                        throws IOException
c to file using 
 serialization.
IOException
public static void writeText(File file,
                             String text)
                      throws IOException
IOException| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||