public class IOUtils extends Object
Provides utility methods related to I/O.
Modifier and Type | Method and Description |
---|---|
static long |
calculateCRC32Checksum(org.springframework.core.io.Resource resource)
Calculates the CRC32 checksum of the given resource.
|
static InputStreamReader |
createInputStreamReader(InputStream inputStream,
String charsetName)
Factory method to create an input stream reader without having to worry about checked exceptions.
|
static InputStream |
getResourceAsStream(String resourceName)
Opens an input stream for the resource with the given name.
|
static InputStream |
getResourceAsStream(URL resource)
Opens an input stream for the given resource.
|
static byte[] |
readInputStreamToBytes(InputStream inputStream)
Reads the given input stream into a byte array.
|
static String |
readInputStreamToString(InputStream inputStream)
Reads the provided input stream into a String.
|
static URL |
resolveResourceName(String resourceName)
Resolves the given resource name to a URL representing the resource.
|
public static final String UTF_8
public static byte[] readInputStreamToBytes(InputStream inputStream)
Reads the given input stream into a byte array.
inputStream
- the input stream to readpublic static String readInputStreamToString(InputStream inputStream)
Reads the provided input stream into a String.
inputStream
- the input stream to readpublic static URL resolveResourceName(String resourceName)
Resolves the given resource name to a URL representing the resource.
resourceName
- the name of the resource to resolvepublic static InputStream getResourceAsStream(String resourceName)
Opens an input stream for the resource with the given name.
resourceName
- the name of the resource for which to open an input streamIllegalArgumentException
- thrown if the resource cannot be foundRuntimeException
- thrown if the resource cannot be openedpublic static InputStream getResourceAsStream(URL resource)
Opens an input stream for the given resource.
resource
- the resource for which to open an input streamRuntimeException
- thrown if the resource cannot be openedpublic static InputStreamReader createInputStreamReader(InputStream inputStream, String charsetName)
Factory method to create an input stream reader without having to worry about checked exceptions.
inputStream
- the underlying input streamcharsetName
- the name of the charsetIllegalArgumentException
- thrown if the encoding is not supportedpublic static long calculateCRC32Checksum(org.springframework.core.io.Resource resource) throws IOException
Calculates the CRC32 checksum of the given resource.
resource
- the resourceIOException
- thrown if the resource cannot be readCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.