Package nbbrd.io
Class Resource
java.lang.Object
nbbrd.io.Resource
- Author:
- Philippe Charles
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidensureClosed(@NonNull Throwable exception, @Nullable Closeable closeable) Returns aFileobject representing this path.@NonNull Optional<InputStream> getResourceAsStream(@NonNull Class<?> anchor, @NonNull String name) Deprecated.static @NonNull InputStreamnewInputStream(@NonNull Class<?> anchor, @NonNull String name) voidprocess(@NonNull URI uri, @NonNull IOConsumer<? super Path> action) Process a classpath resource as a Path.static @NonNull InputStreamuncloseableInputStream(@NonNull InputStream delegate) static @NonNull OutputStreamuncloseableOutputStream(@NonNull OutputStream delegate)
-
Constructor Details
-
Resource
public Resource()
-
-
Method Details
-
getFile
Returns aFileobject representing this path. Where thisPathis associated with the default provider, then this method is equivalent to returning aFileobject constructed with theStringrepresentation of this path.If this path was created by invoking the
FiletoPathmethod then there is no guarantee that theFileobject returned by this method isequalto the originalFile.- Parameters:
path-- Returns:
- an optional
Fileobject representing this path if associated with the default provider
-
getResourceAsStream
@Deprecated @NonNull public @NonNull Optional<InputStream> getResourceAsStream(@NonNull @NonNull Class<?> anchor, @NonNull @NonNull String name) Deprecated.usenewInputStream(Class, String)instead. -
newInputStream
@NonNull public static @NonNull InputStream newInputStream(@NonNull @NonNull Class<?> anchor, @NonNull @NonNull String name) throws IOException - Throws:
IOException
-
ensureClosed
-
closeBoth
- Throws:
IOException
-
process
public void process(@NonNull @NonNull URI uri, @NonNull @NonNull IOConsumer<? super Path> action) throws IOException Process a classpath resource as a Path.- Parameters:
uri-action-- Throws:
IOException- See Also:
-
uncloseableInputStream
@NonNull public static @NonNull InputStream uncloseableInputStream(@NonNull @NonNull InputStream delegate) -
uncloseableOutputStream
@NonNull public static @NonNull OutputStream uncloseableOutputStream(@NonNull @NonNull OutputStream delegate)
-
newInputStream(Class, String)instead.