com.univocity.api.common
Class FileProvider

java.lang.Object
  extended by com.univocity.api.common.FileProvider

public final class FileProvider
extends Object

A FileProvider validates and stores the minimum information required by uniVocity to locate and manipulate files.

Author:
uniVocity Software Pty Ltd - dev@univocity.com

Constructor Summary
FileProvider(File file)
          Creates a provider for the file to be open/written using the default system encoding.
FileProvider(File file, Charset encoding)
          Creates a provider for the file to be open/written using a given encoding
FileProvider(File file, String encoding)
          Creates a provider for the file to be open/written using a given encoding
FileProvider(String file)
          Creates a provider for the file, represented by a path, to be open/written using the default system encoding.
FileProvider(String filePath, Charset encoding)
          Creates a provider for the file, represented by a path, to be open/written using the default system encoding.
FileProvider(String file, String encoding)
          Creates a provider for the file, represented by a path, to be open/written using the default system encoding.
 
Method Summary
 Charset getEncoding()
          Returns the encoding used to manipulate the provided file.
 File getFile()
          Returns the File instance given in the constructor of this class, or null if a path to a resource is being used.
 String getFilePath()
          Returns the resource path given in the constructor of this class, or null if a File is being used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileProvider

public FileProvider(File file)
Creates a provider for the file to be open/written using the default system encoding.

Parameters:
file - the File

FileProvider

public FileProvider(File file,
                    String encoding)
Creates a provider for the file to be open/written using a given encoding

Parameters:
file - the File to be used.
encoding - the name of the encoding that must be used to read from/write to the given file.

FileProvider

public FileProvider(File file,
                    Charset encoding)
Creates a provider for the file to be open/written using a given encoding

Parameters:
file - the File to be used.
encoding - the encoding that must be used to read from/write to the given file.

FileProvider

public FileProvider(String file)
Creates a provider for the file, represented by a path, to be open/written using the default system encoding.

Parameters:
file - the path to a file. It can either be the path to a file in the file system or a resource in the classpath.

FileProvider

public FileProvider(String file,
                    String encoding)
Creates a provider for the file, represented by a path, to be open/written using the default system encoding.

Parameters:
file - the path to a file. It can either be the path to a file in the file system or a resource in the classpath.
encoding - the name of the encoding that must be used to read from/write to the given file.

FileProvider

public FileProvider(String filePath,
                    Charset encoding)
Creates a provider for the file, represented by a path, to be open/written using the default system encoding.

Parameters:
filePath - the path to a file. It can either be the path to a file in the file system or a resource in the classpath.
encoding - the encoding that must be used to read from/write to the given file.
Method Detail

getFile

public final File getFile()
Returns the File instance given in the constructor of this class, or null if a path to a resource is being used.

Returns:
the File to be loaded by uniVocity, or null if a resource path should be used instead.

getEncoding

public final Charset getEncoding()
Returns the encoding used to manipulate the provided file.

Returns:
encoding used to manipulate the provided file.

getFilePath

public final String getFilePath()
Returns the resource path given in the constructor of this class, or null if a File is being used.

Returns:
the path to a resource to be loaded by uniVocity, or null if a File should be used instead.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.