Class InspectedContent
java.lang.Object
org.springframework.boot.buildpack.platform.io.InspectedContent
- All Implemented Interfaces:
Content
Content
that is reads and inspects a source of data only once but allows it to
be consumed multiple times.- Since:
- 2.3.0
- Author:
- Phillip Webb
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface that can be used to inspect content as it is initially read. -
Method Summary
Modifier and TypeMethodDescriptionstatic InspectedContent
of
(InputStream inputStream, InspectedContent.Inspector... inspectors) Factory method to create anInspectedContent
instance from a source input stream.static InspectedContent
of
(Content content, InspectedContent.Inspector... inspectors) Factory method to create anInspectedContent
instance from source content.static InspectedContent
of
(IOConsumer<OutputStream> writer, InspectedContent.Inspector... inspectors) Factory method to create anInspectedContent
instance from a source write method.int
size()
The size of the content in bytes.void
writeTo
(OutputStream outputStream) Write the content to the given output stream.
-
Method Details
-
size
public int size()Description copied from interface:Content
The size of the content in bytes. -
writeTo
Description copied from interface:Content
Write the content to the given output stream.- Specified by:
writeTo
in interfaceContent
- Parameters:
outputStream
- the output stream to write to- Throws:
IOException
- on IO error
-
of
public static InspectedContent of(InputStream inputStream, InspectedContent.Inspector... inspectors) throws IOException Factory method to create anInspectedContent
instance from a source input stream.- Parameters:
inputStream
- the content input streaminspectors
- any inspectors to apply- Returns:
- a new inspected content instance
- Throws:
IOException
- on IO error
-
of
public static InspectedContent of(Content content, InspectedContent.Inspector... inspectors) throws IOException Factory method to create anInspectedContent
instance from source content.- Parameters:
content
- the contentinspectors
- any inspectors to apply- Returns:
- a new inspected content instance
- Throws:
IOException
- on IO error
-
of
public static InspectedContent of(IOConsumer<OutputStream> writer, InspectedContent.Inspector... inspectors) throws IOException Factory method to create anInspectedContent
instance from a source write method.- Parameters:
writer
- a consumer representing the write methodinspectors
- any inspectors to apply- Returns:
- a new inspected content instance
- Throws:
IOException
- on IO error
-