{"id":13803608,"url":"https://github.com/davidmoten/rxjava-file","last_synced_at":"2025-03-17T02:31:42.530Z","repository":{"id":16873206,"uuid":"19633602","full_name":"davidmoten/rxjava-file","owner":"davidmoten","description":"RxJava observables for files including NIO events","archived":false,"fork":false,"pushed_at":"2018-12-06T03:19:47.000Z","size":151,"stargazers_count":82,"open_issues_count":7,"forks_count":17,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-02-27T16:55:31.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidmoten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-10T04:46:22.000Z","updated_at":"2024-02-19T14:35:57.000Z","dependencies_parsed_at":"2022-07-15T10:48:36.601Z","dependency_job_id":null,"html_url":"https://github.com/davidmoten/rxjava-file","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Frxjava-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Frxjava-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Frxjava-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Frxjava-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmoten","download_url":"https://codeload.github.com/davidmoten/rxjava-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841125,"owners_count":20356440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:00:36.139Z","updated_at":"2025-03-17T02:31:42.116Z","avatar_url":"https://github.com/davidmoten.png","language":"Java","readme":"rxjava-file\n===========\n\u003ca href=\"https://travis-ci.org/davidmoten/rxjava-file\"\u003e\u003cimg src=\"https://travis-ci.org/davidmoten/rxjava-file.svg\"/\u003e\u003c/a\u003e\u003cbr/\u003e\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/rxjava-file/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/rxjava-file)\n\nStatus: *released to Maven Central*\n\nRequires Java 7.\n\nObservable utilities for files:\n* tail a file (either lines or byte[]) \n* trigger tail updates using Java 7 and later NIO ```WatchService``` events\n* or trigger tail updates using any Observable\n* stream ```WatchEvent```s from a ```WatchService```\n* backpressure support\n* tested on Linux and Windows 7 (not OSX, help appreciated!)\n\n[Release Notes](RELEASE_NOTES.md)\n\nMaven site reports are [here](http://davidmoten.github.io/rxjava-file/index.html) including [javadoc](http://davidmoten.github.io/rxjava-file/apidocs/index.html).\n\nFor RxJava 2.x see [rxjava2-file](https://github.com/davidmoten/rxjava2-file).\n\n\nGetting started\n----------------\nAdd this maven dependency to your pom.xml:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n  \u003cartifactId\u003erxjava-file\u003c/artifactId\u003e\n  \u003cversion\u003e0.4.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nHow to build\n----------------\n\n```bash\ngit clone https://github.com/davidmoten/rxjava-file\ncd rxjava-file\nmvn clean install \n```\n\nExamples\n--------------\n\n### Tail a text file with NIO\n\nTail the lines of the text log file ```/var/log/server.log``` as an ```Observable\u003cString\u003e```:\n\n```java\nimport com.github.davidmoten.rx.FileObservable;\nimport rx.Observable;\nimport java.io.File; \n \nObservable\u003cString\u003e items = \n     FileObservable.tailer()\n                   .file(\"/var/log/server.log\")\n                   .startPosition(0)\n                   .sampleTimeMs(500)\n                   .chunkSize(8192)\n                   .utf8()\n                   .tailText();\n                     \n```\nor, using defaults (will use default charset):\n```java\nObservable\u003cString\u003e items = \n     FileObservable.tailer()\n                   .file(\"/var/log/server.log\")\n                   .tailText();\n```\n\nNote that if you want the ```Observable\u003cString\u003e``` to be emitting line by line then wrap \nit with a call like ```StringObservable.split(observable, \"\\n\")```. ```StringObservable``` is in the RxJava *rxjava-string* artifact.\n\n### Tail a text file without NIO\n\nThe above example uses a ```WatchService``` to generate ```WatchEvent```s to prompt rereads of the end of the file to perform the tail.\n\nTo use polling instead (say every 5 seconds):\n\n```java\nObservable\u003cString\u003e items = \n     FileObservable.tailer()\n                   .file(new File(\"var/log/server.log\"))\n                   .source(Observable.interval(5, TimeUnit.SECONDS)\n                   .tailText();\n```\n\n### Tail a binary file with NIO\n```java\nObservable\u003cbyte[]\u003e items = \n     FileObservable.tailer()\n                   .file(\"/tmp/dump.bin\")\n                   .tail();\n```\n\n### Tail a binary file without NIO\n```java\nObservable\u003cbyte[]\u003e items = \n     FileObservable.tailer()\n                   .file(\"/tmp/dump.bin\")\n                   .source(Observable.interval(5, TimeUnit.SECONDS)\n                   .tail();\n```\n\n\n","funding_links":[],"categories":["Bindings"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Frxjava-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmoten%2Frxjava-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Frxjava-file/lists"}