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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface that can be used to inspect content as it is initially read. -
Method Summary
Modifier and TypeMethodDescriptionstatic InspectedContentof(InputStream inputStream, InspectedContent.Inspector... inspectors) Factory method to create anInspectedContentinstance from a source input stream.static InspectedContentof(Content content, InspectedContent.Inspector... inspectors) Factory method to create anInspectedContentinstance from source content.static InspectedContentof(IOConsumer<OutputStream> writer, InspectedContent.Inspector... inspectors) Factory method to create anInspectedContentinstance from a source write method.intsize()The size of the content in bytes.voidwriteTo(OutputStream outputStream) Write the content to the given output stream.
-
Method Details
-
size
public int size()Description copied from interface:ContentThe size of the content in bytes. -
writeTo
Description copied from interface:ContentWrite the content to the given output stream.- Specified by:
writeToin 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 anInspectedContentinstance 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 anInspectedContentinstance 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 anInspectedContentinstance 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
-