Package org.springframework.ai
Class ResourceUtils
java.lang.Object
org.springframework.ai.ResourceUtils
Miscellaneous Resource utility methods. Mainly for use within Spring AI
- Author:
- Christian Tzolov
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
ResourceUtils
public ResourceUtils()
-
-
Method Details
-
getText
Retrieves the content of a resource as a UTF-8 encoded string. This method uses Spring's DefaultResourceLoader to load the resource from the given URI and then reads its content as a string using UTF-8 encoding. If an IOException occurs during reading, it is wrapped in a RuntimeException.- Parameters:
uri
- The URI of the resource to be read. This can be any URI supported by Spring's ResourceLoader, such as "classpath:", "file:", or "http:".- Returns:
- The content of the resource as a string.
- Throws:
RuntimeException
- If an error occurs while reading the resource. This exception wraps the original IOException.
-