public final class ResourceTools extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
exists(Object location)
Verifies that a readable source (file/stream) exists at location.
|
static IFile |
getActiveFile()
Returns the currently active file in the workbench.
|
static InputStream |
getInputStream(Object location) |
static Object |
getResource(Object location)
Get an existing resource (file/folder/URI).
|
static Object |
resolveFile(Object location,
Object parent,
boolean exists)
Resolve a file from a given input location.
|
static Object |
resolveFolder(Object location,
Object parent,
boolean exists)
Resolve a folder from a given input location.
|
static String |
resourceToString(Object location)
Reads from a resource into a string.
|
static String |
toAbsoluteLocation(Object location,
Object parent)
Resolve a given location to an absolute location URI.
|
static IPath |
toPath(String location)
Convert a location to a path in the workspace.
|
static String |
toProjectRelativeLocation(Object location,
Object parent) |
static String |
toString(InputStream stream)
Convert an input stream to a string.
|
static String |
toString(Reader reader)
Read characters from a
Reader and return its string representation. |
static URI |
toURI(IPath path)
|
public static Object resolveFile(Object location, Object parent, boolean exists)
public static Object resolveFolder(Object location, Object parent, boolean exists)
location - folder location to be resolvedparent - location of parent resourceexists - return folder only if it existsIContainer, File or nullpublic static String toProjectRelativeLocation(Object location, Object parent)
public static String toAbsoluteLocation(Object location, Object parent)
location - (relative) locationparent - parent object to resolve fromnullpublic static boolean exists(Object location)
location - location to verifytrue when location is readablepublic static Object getResource(Object location)
public static InputStream getInputStream(Object location)
public static String resourceToString(Object location)
null in case of errors and logs the error to the system
logger.location - location to look upnull in case of errorpublic static URI toURI(IPath path)
path - The path to convertpublic static IPath toPath(String location)
location - location to convert (workspace://...)public static String toString(InputStream stream) throws IOException
stream - input string to read fromIOException - thrown on problems with input streampublic static String toString(Reader reader) throws IOException
Reader and return its string representation. Can be used to convert an InputStream to a string.reader - reader to read fromIOException - when reader is not accessiblepublic static IFile getActiveFile()
null in case of error.