Modifier and Type | Class and Description |
---|---|
static class |
FileObservable.Builder |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_BYTES_PER_EMISSION |
Constructor and Description |
---|
FileObservable() |
Modifier and Type | Method and Description |
---|---|
static rx.Observable<WatchEvent<?>> |
from(File file,
rx.functions.Action0 onWatchStarted,
WatchEvent.Kind<?>... kinds)
If file does not exist at subscribe time then is assumed to not be a
directory.
|
static rx.Observable<WatchEvent<?>> |
from(File file,
WatchEvent.Kind<?>... kinds)
If file does not exist at subscribe time then is assumed to not be a
directory.
|
static rx.Observable<WatchEvent<?>> |
from(WatchService watchService)
|
static FileObservable.Builder |
tailer() |
static rx.Observable<byte[]> |
tailFile(File file,
long startPosition,
long sampleTimeMs,
int chunkSize)
Returns an
Observable that uses NIO WatchService (and a
dedicated thread) to push modified 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 chunkSize,
rx.Observable<?> events)
Returns an
Observable that uses given given observable to push
modified events to an observable that reads and reports new sequences of
bytes to a subscriber. |
static rx.Observable<String> |
tailTextFile(File file,
long startPosition,
int chunkSize,
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 modified events to an observable that reads and
reports new lines to a subscriber. |
static rx.Observable<WatchService> |
watchService(File file,
WatchEvent.Kind<?>... kinds)
Creates a
WatchService on subscribe for the given file and event
kinds. |
public static final int DEFAULT_MAX_BYTES_PER_EMISSION
public static final rx.Observable<byte[]> tailFile(File file, long startPosition, long sampleTimeMs, int chunkSize)
Observable
that uses NIO WatchService
(and a
dedicated thread) to push modified 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 millischunkSize
- max array size of each element emitted by the Observable. Is
also used as the buffer size for reading from the file. Try
DEFAULT_MAX_BYTES_PER_EMISSION
if you
don't know what to put here.public static final rx.Observable<byte[]> tailFile(File file, long startPosition, long sampleTimeMs, int chunkSize, rx.Observable<?> events)
Observable
that uses given given observable to push
modified events to an observable that reads and reports new sequences of
bytes to a subscriber. The NIO WatchService
MODIFY and OVERFLOW
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 create events are not sampled and are always passed
through.file
- the file to tailstartPosition
- start tailing file at position in bytessampleTimeMs
- sample time in millis for MODIFY and OVERFLOW eventschunkSize
- max array size of each element emitted by the Observable. Is
also used as the buffer size for reading from the file. Try
DEFAULT_MAX_BYTES_PER_EMISSION
if you
don't know what to put here.public 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 modified events to an observable that reads and
reports new lines to a subscriber. The NIO WatchService MODIFY and
OVERFLOW 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 create events are not sampled and are always
passed through.file
- the file to tailstartPosition
- start tailing file at position in bytessampleTimeMs
- sample time in millis for MODIFY and OVERFLOW eventscharset
- the character set to use to decode the bytes to a stringpublic static final rx.Observable<String> tailTextFile(File file, long startPosition, int chunkSize, 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 tail, cannot be nullstartPosition
- 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<WatchEvent<?>> from(WatchService watchService)
watchService
- WatchService
to generate events for@SafeVarargs public static final rx.Observable<WatchEvent<?>> from(File file, WatchEvent.Kind<?>... kinds)
WatchService
is set up on its parent and
WatchEvent
s 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 emitpublic static final rx.Observable<WatchEvent<?>> from(File file, rx.functions.Action0 onWatchStarted, WatchEvent.Kind<?>... kinds)
WatchService
is set up on its parent and
WatchEvent
s 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
- onWatchStarted
- called when WatchService is createdkinds
- @SafeVarargs public static final rx.Observable<WatchService> watchService(File file, WatchEvent.Kind<?>... kinds)
WatchService
on subscribe for the given file and event
kinds.file
- the file to watchkinds
- event kinds to watch forpublic static FileObservable.Builder tailer()
Copyright © 2013–2015. All rights reserved.