spring-framework / org.springframework.core.io

Package org.springframework.core.io

Types

ByteArrayResource

open class ByteArrayResource : AbstractResource

Resource implementation for a given byte array.

Creates a ByteArrayInputStream for the given byte array.

Useful for loading content from any given byte array, without having to resort to a single-use InputStreamResource. Particularly useful for creating mail attachments from local content, where JavaMail needs to be able to read the stream multiple times.

ClassRelativeResourceLoader

open class ClassRelativeResourceLoader : DefaultResourceLoader

ResourceLoader implementation that interprets plain resource paths as relative to a given java.lang.Class.

ContextResource

interface ContextResource : Resource

Extended interface for a resource that is loaded from an enclosing 'context', e.g. from a javax.servlet.ServletContext but also from plain classpath paths or relative file system paths (specified without an explicit prefix, hence applying relative to the local ResourceLoader's context).

FileSystemResourceLoader

open class FileSystemResourceLoader : DefaultResourceLoader

ResourceLoader implementation that resolves plain paths as file system resources rather than as class path resources (the latter is DefaultResourceLoader's default strategy).

NOTE: Plain paths will always be interpreted as relative to the current VM working directory, even if they start with a slash. (This is consistent with the semantics in a Servlet container.) Use an explicit "file:" prefix to enforce an absolute file path.

org.springframework.context.support.FileSystemXmlApplicationContext is a full-fledged ApplicationContext implementation that provides the same resource path resolution strategy.

FileUrlResource

open class FileUrlResource : UrlResource, WritableResource

Subclass of UrlResource which assumes file resolution, to the degree of implementing the WritableResource interface for it.

This is the class resolved by DefaultResourceLoader for a "file:..." URL location, allowing a downcast to WritableResource for it.

Alternatively, for direct construction from a java.io.File handle, consider using FileSystemResource. For an NIO java.nio.file.Path, consider using PathResource instead.

InputStreamResource

open class InputStreamResource : AbstractResource

Resource implementation for a given InputStream.

Should only be used if no other specific Resource implementation is applicable. In particular, prefer ByteArrayResource or any of the file-based Resource implementations where possible.

In contrast to other Resource implementations, this is a descriptor for an already opened resource - therefore returning true from #isOpen(). Do not use an InputStreamResource if you need to keep the resource descriptor somewhere, or if you need to read from a stream multiple times.

PathResource

open class PathResource : AbstractResource, WritableResource

Resource implementation for java.nio.file.Path handles. Supports resolution as File, and also as URL. Implements the extended WritableResource interface.

VfsUtils

abstract class VfsUtils

Utility for detecting and accessing JBoss VFS in the classpath.

As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package org.jboss.vfs) and is in particular compatible with JBoss AS 7 and WildFly 8.

Thanks go to Marius Bogoevici for the initial patch. Note: This is an internal class and should not be used outside the framework.

WritableResource

interface WritableResource : Resource

Extended interface for a resource that supports writing to it. Provides an OutputStream accessor.