Package com.norconex.commons.lang.file
Class WebFile
java.lang.Object
com.norconex.commons.lang.file.WebFile
Access a web-based file as a local file.
File is lazily downloaded the first time it is accessed only, unless it
gets deleted, in which case it will be downloaded again.
Use this class for simple scenarios. If more complex ones are required
(e.g., authentication, proxy, etc), use a different approach.
All this
Path methods are applied on the downloaded file.- Since:
- 2.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a web file using the OS temp directory + "webfiles" as the local download location, and the URL "file" name as the local file name.Creates a web file using a local path to store the dowloaded file.Creates a web file using the OS temp directory + "webfiles" as the local download location, and the URL "file" name as the local file name.Creates a web file using a local path to store the dowloaded file. -
Method Summary
Modifier and TypeMethodDescriptionintstatic WebFileCreates a web file using the OS temp directory + "webfiles" as the local download location, and the given name as the local file name.static WebFileCreates a web file using the given directory as the local download location, and the URL "file" name as the local file name.static WebFileCreates a web file using the given directory as the local download location, and the given name as the local file name.static WebFileCreates a web file using the OS temp directory + "webfiles" as the local download location, and the given name as the local file name.static WebFileCreates a web file using the given directory as the local download location, and the URL "file" name as the local file name.static WebFileCreates a web file using the given directory as the local download location, and the given name as the local file name.protected voidbooleanbooleanbooleangetName(int index) intgetRoot()getUrl()inthashCode()booleaniterator()register(WatchService watcher, WatchEvent.Kind<?>... events) register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) relativize(Path other) resolveSibling(String other) resolveSibling(Path other) booleanstartsWith(String other) booleanstartsWith(Path other) subpath(int beginIndex, int endIndex) toFile()toRealPath(LinkOption... options) toString()toUri()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
WebFile
Creates a web file using the OS temp directory + "webfiles" as the local download location, and the URL "file" name as the local file name.- Parameters:
url- URL to download
-
WebFile
Creates a web file using a local path to store the dowloaded file. If the local file argument isnull, invoking this method is the same as invokingWebFile(URL)- Parameters:
url- URL to downloadlocalFile- full file path to local file destination
-
WebFile
Creates a web file using the OS temp directory + "webfiles" as the local download location, and the URL "file" name as the local file name.- Parameters:
url- URL to download
-
WebFile
Creates a web file using a local path to store the dowloaded file. If the local file argument isnull, invoking this method is the same as invokingWebFile(URL)- Parameters:
url- URL to downloadlocalFile- full file path to local file destination
-
-
Method Details
-
create
Creates a web file using the given directory as the local download location, and the URL "file" name as the local file name.- Parameters:
url- URL to downloadlocalDir- full directory path to local directory destination- Returns:
- web file
-
create
Creates a web file using the given directory as the local download location, and the given name as the local file name.- Parameters:
url- URL to downloadlocalDir- full directory path to local directory destinationlocalName- local file name- Returns:
- web file
-
create
Creates a web file using the OS temp directory + "webfiles" as the local download location, and the given name as the local file name.- Parameters:
url- URL to downloadlocalName- local file name- Returns:
- web file
-
create
Creates a web file using the given directory as the local download location, and the URL "file" name as the local file name.- Parameters:
url- URL to downloadlocalDir- full directory path to local directory destination- Returns:
- web file
-
create
Creates a web file using the given directory as the local download location, and the given name as the local file name.- Parameters:
url- URL to downloadlocalDir- full directory path to local directory destinationlocalName- local file name- Returns:
- web file
-
create
Creates a web file using the OS temp directory + "webfiles" as the local download location, and the given name as the local file name.- Parameters:
url- URL to downloadlocalName- local file name- Returns:
- web file
-
getUrl
-
download
-
getFileSystem
- Specified by:
getFileSystemin interfacePath
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfacePath
-
getRoot
-
getFileName
- Specified by:
getFileNamein interfacePath
-
getParent
-
getNameCount
public int getNameCount()- Specified by:
getNameCountin interfacePath
-
getName
-
subpath
-
startsWith
- Specified by:
startsWithin interfacePath
-
startsWith
- Specified by:
startsWithin interfacePath
-
endsWith
-
endsWith
-
normalize
-
resolve
-
resolve
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
relativize
- Specified by:
relativizein interfacePath
-
toUri
-
toAbsolutePath
- Specified by:
toAbsolutePathin interfacePath
-
toRealPath
- Specified by:
toRealPathin interfacePath- Throws:
IOException
-
toFile
-
register
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException - Specified by:
registerin interfacePath- Specified by:
registerin interfaceWatchable- Throws:
IOException
-
register
- Specified by:
registerin interfacePath- Specified by:
registerin interfaceWatchable- Throws:
IOException
-
iterator
-
toString
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<Path>- Specified by:
compareToin interfacePath
-
equals
-