{"id":17808170,"url":"https://github.com/kherge/java.resource","last_synced_at":"2025-08-13T11:33:31.448Z","repository":{"id":56762178,"uuid":"189524450","full_name":"kherge/java.resource","owner":"kherge","description":"A library to simplify resource access.","archived":false,"fork":false,"pushed_at":"2019-06-01T03:20:50.000Z","size":87,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-27T15:33:37.015Z","etag":null,"topics":["jar","java","resources"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kherge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-31T03:56:08.000Z","updated_at":"2024-09-06T17:53:30.000Z","dependencies_parsed_at":"2022-08-16T02:01:01.131Z","dependency_job_id":null,"html_url":"https://github.com/kherge/java.resource","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kherge%2Fjava.resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kherge%2Fjava.resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kherge%2Fjava.resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kherge%2Fjava.resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kherge","download_url":"https://codeload.github.com/kherge/java.resource/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229759869,"owners_count":18119874,"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":["jar","java","resources"],"created_at":"2024-10-27T15:08:55.666Z","updated_at":"2024-12-14T22:11:37.204Z","avatar_url":"https://github.com/kherge.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/kherge/java.resource.svg?branch=master)](https://travis-ci.org/kherge/java.resource)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=kherge_java.resource\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=kherge_java.resource)\n\nResource\n========\n\nA library to simplify resource access.\n\nResource access behaves differently depending on context. For example, resources can be on the file\nsystem (during testing) or contained in a JAR (after a build). This library provides a more\nconsistent method of accessing resource by eliminating this distinction.\n\n```java\nResource resource = new Resource(MyClass.class.getClassLoader());\n\nSystem.out.println(resource.getAsString(\"hello-world.txt\", \"utf-8\"));\nSystem.out.println(resource.list(\"path/to/folder\"));\n```\n\nRequirements\n------------\n\n- Java 8\n\nInstallation\n------------\n\n### Gradle\n\n```groovy\ncompile 'io.herrera.kevin:resource:1.1.0'\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.herrera.kevin\u003c/groupId\u003e\n  \u003cartifactId\u003eresource\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nUsage\n-----\n\n```java\nimport io.herrera.kevin.resource.Resource;\nimport java.io.InputStream;\nimport java.nio.file.Path;\n\nclass Example {\n    public static void main() {\n        try {\n\n            // The manager is created using the desired class loader.\n            Resource resource = new Resource(Example.class.getClassLoader());\n\n            // A resource can be retrieved as an InputStream.\n            InputStream stream = resource.getAsInputStream(\"my-resource.txt\");\n\n            // A resource can be retrieved as a file path.\n            Path path = resource.getAsPath(\"my-resource.txt\");\n\n            // A resource can be retrieved as a string.\n            String string = resource.getAsString(\"my-resource.txt\");\n\n            // List resources in a folder.\n            List\u003cString\u003e resources = resource.list(\"path/to/folder\");\n\n            // List matching resources in a folder.\n            // (This is more performant than using list() and then filtering.)\n            List\u003cString\u003e resources = resource.listMatch(\"path/to/folder\", \".+pattern.+\");\n\n            // Stream resources in a folder.\n            try (Stream\u003cString\u003e resources = resource.stream(\"path/to/folder\")) {\n                resources.forEach(name -\u003e System.out.println(resource.getAsString(name));\n            }\n\n        } catch (ResourceException exception) {\n\n            // If a resource could not be retrieved or listed, this exception is thrown.\n            throw exception;\n\n        }\n    }\n}\n```\n\nLicense\n-------\n\nThis library is made available under the MIT and Apache 2.0 licenses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkherge%2Fjava.resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkherge%2Fjava.resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkherge%2Fjava.resource/lists"}