Class FileSystemResource
- java.lang.Object
-
- org.drools.util.io.BaseResource
-
- org.drools.util.io.FileSystemResource
-
- All Implemented Interfaces:
Externalizable,Serializable,InternalResource,org.kie.api.io.Resource
public class FileSystemResource extends BaseResource implements InternalResource, Externalizable
Borrowed gratuitously from Spring under ASL2.0.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.drools.util.io.BaseResource
bytes
-
-
Constructor Summary
Constructors Constructor Description FileSystemResource()FileSystemResource(File file)Create a new FileSystemResource from a File handle.FileSystemResource(File file, String encoding)FileSystemResource(String path)Create a new FileSystemResource from a file path.FileSystemResource(String path, String encoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)StringgetEncoding()FilegetFile()InputStreamgetInputStream()This implementation opens a FileInputStream for the underlying file.ReadergetReader()URLgetURL()This implementation returns a URL for the underlying file.inthashCode()booleanhasURL()booleanisDirectory()Collection<org.kie.api.io.Resource>listResources()voidreadExternal(ObjectInput in)StringtoString()voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.drools.util.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.util.io.InternalResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, setCategories, setConfiguration, setDescription, setResourceType
-
-
-
-
Constructor Detail
-
FileSystemResource
public FileSystemResource()
-
FileSystemResource
public FileSystemResource(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(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
-
-
Method Detail
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classBaseResource- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classBaseResource- Throws:
IOExceptionClassNotFoundException
-
getEncoding
public String getEncoding()
- Specified by:
getEncodingin interfaceInternalResource
-
getInputStream
public InputStream getInputStream() throws IOException
This implementation opens a FileInputStream for the underlying file.- Specified by:
getInputStreamin interfaceorg.kie.api.io.Resource- Throws:
IOException- See Also:
FileInputStream
-
getReader
public Reader getReader() throws IOException
- Specified by:
getReaderin interfaceorg.kie.api.io.Resource- Throws:
IOException
-
getFile
public File getFile()
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectoryin interfaceInternalResource
-
listResources
public Collection<org.kie.api.io.Resource> listResources()
- Specified by:
listResourcesin interfaceInternalResource
-
getURL
public URL getURL() throws IOException
This implementation returns a URL for the underlying file.- Specified by:
getURLin interfaceInternalResource- Throws:
IOException- See Also:
File.toURI()
-
hasURL
public boolean hasURL()
- Specified by:
hasURLin interfaceInternalResource
-
toString
public String toString()
- Overrides:
toStringin classBaseResource
-
equals
public boolean equals(Object object)
- Overrides:
equalsin classBaseResource
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBaseResource
-
-