Class FileSystemResource
- java.lang.Object
-
- org.drools.io.BaseResource
-
- org.drools.io.FileSystemResource
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,InternalResource,org.kie.api.io.Resource
public class FileSystemResource extends BaseResource implements InternalResource, java.io.Externalizable
Borrowed gratuitously from Spring under ASL2.0.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.drools.io.BaseResource
bytes
-
-
Constructor Summary
Constructors Constructor Description FileSystemResource()FileSystemResource(java.io.File file)Create a new FileSystemResource from a File handle.FileSystemResource(java.io.File file, java.lang.String encoding)FileSystemResource(java.lang.String path)Create a new FileSystemResource from a file path.FileSystemResource(java.lang.String path, java.lang.String encoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)java.lang.StringgetEncoding()java.io.FilegetFile()java.io.InputStreamgetInputStream()This implementation opens a FileInputStream for the underlying file.java.io.ReadergetReader()java.net.URLgetURL()This implementation returns a URL for the underlying file.inthashCode()booleanhasURL()booleanisDirectory()java.util.Collection<org.kie.api.io.Resource>listResources()voidreadExternal(java.io.ObjectInput in)java.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class org.drools.io.BaseResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, getSourcePath, getTargetPath, setCategories, setConfiguration, setDescription, setResourceType, setSourcePath, setTargetPath
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.io.InternalResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, setCategories, setConfiguration, setDescription, setResourceType
-
-
-
-
Constructor Detail
-
FileSystemResource
public FileSystemResource()
-
FileSystemResource
public FileSystemResource(java.io.File file)
Create a new FileSystemResource from a File handle.Note: When building relative resources via
#createRelative, the relative path will apply at the same directory level: e.g. new File("C:/dir1"), relative path "dir2" -> "C:/dir2"! If you prefer to have relative paths built underneath the given root directory, use theconstructor with a file pathto append a trailing slash to the root path: "C:/dir1/", which indicates this directory as root for all relative paths.- Parameters:
file- a File handle
-
FileSystemResource
public FileSystemResource(java.io.File file, java.lang.String encoding)
-
FileSystemResource
public FileSystemResource(java.lang.String path)
Create a new FileSystemResource from a file path.Note: When building relative resources via
#createRelative, it makes a difference whether the specified resource base path here ends with a slash or not. In the case of "C:/dir1/", relative paths will be built underneath that root: e.g. relative path "dir2" -> "C:/dir1/dir2". In the case of "C:/dir1", relative paths will apply at the same directory level: relative path "dir2" -> "C:/dir2".- Parameters:
path- a file path
-
FileSystemResource
public FileSystemResource(java.lang.String path, java.lang.String encoding)
-
-
Method Detail
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classBaseResource- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classBaseResource- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
getEncoding
public java.lang.String getEncoding()
- Specified by:
getEncodingin interfaceInternalResource
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionThis implementation opens a FileInputStream for the underlying file.- Specified by:
getInputStreamin interfaceorg.kie.api.io.Resource- Throws:
java.io.IOException- See Also:
FileInputStream
-
getReader
public java.io.Reader getReader() throws java.io.IOException- Specified by:
getReaderin interfaceorg.kie.api.io.Resource- Throws:
java.io.IOException
-
getFile
public java.io.File getFile()
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectoryin interfaceInternalResource
-
listResources
public java.util.Collection<org.kie.api.io.Resource> listResources()
- Specified by:
listResourcesin interfaceInternalResource
-
getURL
public java.net.URL getURL() throws java.io.IOExceptionThis implementation returns a URL for the underlying file.- Specified by:
getURLin interfaceInternalResource- Throws:
java.io.IOException- See Also:
File.toURI()
-
hasURL
public boolean hasURL()
- Specified by:
hasURLin interfaceInternalResource
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBaseResource
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classBaseResource
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBaseResource
-
-