public class FileRetriever extends Object
| Modifier and Type | Field and Description |
|---|---|
static File |
CACHE_DIR
The cache dir.
|
static boolean |
FIND_LOCAL
Are we allowed to search for local files?.
|
static boolean |
FIND_REMOTE
Are we allowed to search for files on the Internet?.
|
| Constructor and Description |
|---|
FileRetriever() |
| Modifier and Type | Method and Description |
|---|---|
protected static String |
copy(URI from,
File to,
boolean local)
Copy a file.
|
protected static String |
download(URI from,
File to,
boolean downloadAnyway,
Map<String,String> addidionalHeaders)
Download a file from a remote location..
|
static String |
getFile(URI file,
File dest)
Retrieves a file from an URI.
|
static String |
getFile(URI file,
File dest,
Map<String,String> additionalDownloadHeaders)
Retrieves a file from an URI.
|
static URI |
getUri(String href,
URI base)
Compute an URI location.
|
static boolean |
setUpCache(File directory)
Sets the up caching.
|
public static File CACHE_DIR
public static boolean FIND_LOCAL
public static boolean FIND_REMOTE
public static boolean setUpCache(File directory) throws IOException
directory - the directory to write toIOExceptionpublic static URI getUri(String href, URI base) throws URISyntaxException, IOException
href - the hrefbase - the base URIURISyntaxException - the URI syntax exceptionIOException - the IO exceptionprotected static String copy(URI from, File to, boolean local) throws IOException
from - the originto - the destinationIOException - the IO exceptionprotected static String download(URI from, File to, boolean downloadAnyway, Map<String,String> addidionalHeaders) throws IOException
from - the originto - the destinationIOException - the IO exceptionpublic static String getFile(URI file, File dest) throws IOException, URISyntaxException
file - the URI to the filedest - the destination to write toIOException - Signals that an I/O exception has occurred.URISyntaxException - thrown if file or base have a strange formatpublic static String getFile(URI file, File dest, Map<String,String> additionalDownloadHeaders) throws IOException, URISyntaxException
{
@code Map<String, String> addHeaders = new HashMap<String, String> ();
addHeaders.put ("Accept", "text/html");
FileRetriever.getFile (new URI ("URL"), DESTFILE, addHeaders);
}
file - the URI to the filedest - the destination to write toadditionalDownloadHeaders - the additional headers to be supplied in case of a downloadIOException - Signals that an I/O exception has occurred.URISyntaxException - thrown if file or base have a strange formatCopyright © 2017. All rights reserved.