/** * Loads properties from classpath file(s). Properties are specified using wildcards. */ public static Properties loadFromClasspath(final Properties p, final String... rootTemplate) { ClassScanner.create() .registerEntryConsumer(entryData -> UncheckedException.runAndWrapException(() -> p.load(entryData.openInputStream()))) .includeResources(true) .ignoreException(true) .excludeAllEntries(true) .includeEntries(rootTemplate) .scanDefaultClasspath(); return p; }
/** * Loads properties from classpath file(s). Properties are specified using wildcards. */ public static Properties loadFromClasspath(final Properties p, final String... rootTemplate) { ClassScanner.create() .registerEntryConsumer(entryData -> UncheckedException.runAndWrapException(() -> p.load(entryData.openInputStream()))) .includeResources(true) .ignoreException(true) .excludeAllEntries(true) .includeEntries(rootTemplate) .scanDefaultClasspath(); return p; }
/** * Loads props and properties from the classpath. */ public Props loadFromClasspath(final String... patterns) { ClassScanner.create() .registerEntryConsumer(entryData -> { String usedEncoding = JoddCore.encoding; if (StringUtil.endsWithIgnoreCase(entryData.name(), ".properties")) { usedEncoding = StringPool.ISO_8859_1; } final String encoding = usedEncoding; UncheckedException.runAndWrapException(() -> load(entryData.openInputStream(), encoding)); }) .includeResources(true) .ignoreException(true) .excludeCommonJars() .excludeAllEntries(true) .includeEntries(patterns) .scanDefaultClasspath() .start(); return this; }
/** * Reads stream bytes. Since stream can be read only once, the byte content * is cached. */ public byte[] readBytes() throws IOException { openInputStream(); if (inputStreamBytes == null) { inputStreamBytes = StreamUtil.readBytes(inputStream); } return inputStreamBytes; }
/** * Loads props and properties from the classpath. */ public Props loadFromClasspath(final String... patterns) { ClassScanner.create() .registerEntryConsumer(entryData -> { String usedEncoding = JoddCore.encoding; if (StringUtil.endsWithIgnoreCase(entryData.name(), ".properties")) { usedEncoding = StringPool.ISO_8859_1; } final String encoding = usedEncoding; UncheckedException.runAndWrapException(() -> load(entryData.openInputStream(), encoding)); }) .includeResources(true) .ignoreException(true) .excludeCommonJars() .excludeAllEntries(true) .includeEntries(patterns) .scanDefaultClasspath() .start(); return this; }
/** * Reads stream bytes. Since stream can be read only once, the byte content * is cached. */ public byte[] readBytes() throws IOException { openInputStream(); if (inputStreamBytes == null) { inputStreamBytes = StreamUtil.readBytes(inputStream); } return inputStreamBytes; }