net.sf.staccatocommons.io
Class Files

java.lang.Object
  extended by net.sf.staccatocommons.io.Files

public class Files
extends Object

Simple Applicatives for dealing with Files

Author:
flbulgarelli

Constructor Summary
Files()
           
 
Method Summary
static net.sf.staccatocommons.defs.function.Function<File,String> fileName()
          Answers a function that returns the name of a file
static net.sf.staccatocommons.defs.function.Function<File,String> filePath()
          Answers a function that returns the path of a file
protected static
<T> T
handleFileNotFound(File file, FileNotFoundException e)
           
static FileChannel openChannel(File file)
          Opens an FileChannel for the given file.
static FileInputStream openInputStream(File file)
          Opens an InputStream for the given file.
static Reader openReader(File file)
          Opens a Reader for the given file.
static net.sf.staccatocommons.defs.predicate.Predicate<File> suffix(String... suffixes)
          Answers a predicate that evaluates if a file ends with a given suffix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Files

public Files()
Method Detail

fileName

@Constant
public static net.sf.staccatocommons.defs.function.Function<File,String> fileName()
Answers a function that returns the name of a file

Returns:
a Function that returns arg.getName()

filePath

@Constant
public static net.sf.staccatocommons.defs.function.Function<File,String> filePath()
Answers a function that returns the path of a file

Returns:
a Function that returns arg.getPath()

suffix

public static net.sf.staccatocommons.defs.predicate.Predicate<File> suffix(@NonNull
                                                                           String... suffixes)
Answers a predicate that evaluates if a file ends with a given suffix

Parameters:
suffixes -
Returns:
a new Predicate
See Also:
SuffixFileFilter

openReader

public static Reader openReader(@NonNull
                                File file)
Opens a Reader for the given file. The file must exist, must be readable, and must be a regular file.

Parameters:
file -
Returns:
a new Reader

openInputStream

public static FileInputStream openInputStream(@NonNull
                                              File file)
Opens an InputStream for the given file. The file must exist, must be readable, and must be a regular file.

Parameters:
file -
Returns:
a new InputStream

openChannel

public static FileChannel openChannel(@NonNull
                                      File file)
Opens an FileChannel for the given file. The file must exist, must be readable, and must be a regular file.

Parameters:
file -
Returns:
openInputStream(file).getChannel()

handleFileNotFound

protected static <T> T handleFileNotFound(File file,
                                          FileNotFoundException e)


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.