| Constructor and Description |
|---|
FileObservable() |
| Modifier and Type | Method and Description |
|---|---|
static rx.Observable<java.nio.file.WatchEvent<?>> |
from(File file,
java.nio.file.WatchEvent.Kind<?>... kinds)
If file does not exist at subscribe time then is assumed to not be a
directory.
|
static rx.Observable<java.nio.file.WatchEvent<?>> |
from(java.nio.file.WatchService watchService)
|
static rx.Observable<byte[]> |
tailFile(File file,
long startPosition,
long sampleTimeMs)
Returns an
Observable that uses NIO WatchService (and a dedicated
thread) to push modify events to an observable that reads and reports new
sequences of bytes to a subscriber. |
static rx.Observable<byte[]> |
tailFile(File file,
long startPosition,
long sampleTimeMs,
int maxBytesPerEmission)
Returns an
Observable that uses NIO WatchService (and a dedicated
thread) to push modify events to an observable that reads and reports new
sequences of bytes to a subscriber. |
static rx.Observable<String> |
tailTextFile(File file,
long startPosition,
Charset charset,
rx.Observable<?> events)
Returns an
Observable of String that uses the given events stream
to trigger checks on file change so that new lines can be read and
emitted. |
static rx.Observable<String> |
tailTextFile(File file,
long startPosition,
long sampleTimeMs,
Charset charset)
Returns an
Observable that uses NIO WatchService (and a dedicated
thread) to push modify events to an observable that reads and reports new
lines to a subscriber. |
static rx.Observable<java.nio.file.WatchService> |
watchService(File file,
java.nio.file.WatchEvent.Kind<?>... kinds)
Creates a
WatchService on subscribe for the given file and event
kinds. |
public static final rx.Observable<byte[]> tailFile(File file, long startPosition, long sampleTimeMs, int maxBytesPerEmission)
Observable that uses NIO WatchService (and a dedicated
thread) to push modify events to an observable that reads and reports new
sequences of bytes to a subscriber. The NIO WatchService events are
sampled according to sampleTimeMs so that lots of discrete
activity on a file (for example a log file with very frequent entries)
does not prompt an inordinate number of file reads to pick up changes.file - the file to tailstartPosition - start tailing file at position in bytessampleTimeMs - sample time in millismaxBytesPerEmission - max array size of each element emitted by the Observable. Is
also used as the buffer size for reading from the file.public static final rx.Observable<byte[]> tailFile(File file, long startPosition, long sampleTimeMs)
Observable that uses NIO WatchService (and a dedicated
thread) to push modify events to an observable that reads and reports new
sequences of bytes to a subscriber. The NIO WatchService events are
sampled according to sampleTimeMs so that lots of discrete
activity on a file (for example a log file with very frequent entries)
does not prompt an inordinate number of file reads to pick up changes.
Max size of byte array emitted by the Observable is 8192 bytes. sfile - the file to tailstartPosition - start tailing file at position in bytessampleTimeMs - sample time in millispublic static final rx.Observable<String> tailTextFile(File file, long startPosition, long sampleTimeMs, Charset charset)
Observable that uses NIO WatchService (and a dedicated
thread) to push modify events to an observable that reads and reports new
lines to a subscriber. The NIO WatchService events are sampled according
to sampleTimeMs so that lots of discrete activity on a file
(for example a log file with very frequent entries) does not prompt an
inordinate number of file reads to pick up changes.file - the file to tailstartPosition - start tailing file at position in bytessampleTimeMs - sample time in millischarset - the character set to use to decode the bytes to a stringpublic static final rx.Observable<String> tailTextFile(File file, long startPosition, Charset charset, rx.Observable<?> events)
Observable of String that uses the given events stream
to trigger checks on file change so that new lines can be read and
emitted.file - the file to tailstartPosition - start tailing file at position in bytescharset - the character set to use to decode the bytes to a stringevents - trigger a check for file changes. Use
Observable.interval(long, TimeUnit) for example.public static final rx.Observable<java.nio.file.WatchEvent<?>> from(java.nio.file.WatchService watchService)
watchService - WatchService to generate events for@SafeVarargs public static final rx.Observable<java.nio.file.WatchEvent<?>> from(File file, java.nio.file.WatchEvent.Kind<?>... kinds)
WatchService is set up on its parent and
WatchEvents of the given kinds are filtered to concern the file
in question. If the file is a directory then a WatchService is
set up on the directory and all events are passed through of the given
kinds.file - file to watchkinds - event kinds to watch for and emit@SafeVarargs public static final rx.Observable<java.nio.file.WatchService> watchService(File file, java.nio.file.WatchEvent.Kind<?>... kinds)
WatchService on subscribe for the given file and event
kinds.file - the file to watchkinds - event kinds to watch forCopyright © 2013-2014. All Rights Reserved.