|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.cau.cs.kieler.kwebs.util.Resources
public final class Resources
Utilities for accessing resources such as files or bundled resources.
Method Summary | |
---|---|
static InputStream |
getFileOrPluginResourceStream(String pluginid,
String resource)
Returns an input stream on a file specified by resource . |
static InputStream |
getResourceStream(String pluginid,
String resource)
Creates an input stream to a bundled resource. |
static byte[] |
readFileAsByteArray(String path)
Reads a file. |
static String |
readFileAsString(String path)
Reads a file. |
static byte[] |
readFileOrPluginResourceAsByteArray(String pluginid,
String resource)
Reads data from a path specified by resource . |
static byte[] |
readStreamAsByteArray(InputStream stream)
Reads from a stream with fixed size. |
static String |
readStreamAsString(InputStream stream)
Reads from a stream with fixed size. |
static void |
writeFile(String path,
byte[] data)
Writes a file from a string. |
static void |
writeFile(String path,
InputStream stream)
Writes a file from an input stream. |
static void |
writeFile(String path,
String data)
Writes a file from a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String readFileAsString(String path) throws IOException
path
- path to the file
IOException
public static byte[] readFileAsByteArray(String path) throws IOException
path
- path to the file
IOException
public static void writeFile(String path, String data) throws IOException
path
- path to the filedata
- string with file contents
IOException
public static void writeFile(String path, byte[] data) throws IOException
path
- path to the filedata
- byte array file contents
IOException
public static void writeFile(String path, InputStream stream) throws IOException
path
- path to the filestream
- stream with file contents
IOException
public static String readStreamAsString(InputStream stream) throws IOException
stream
- the stream to be read
IOException
public static byte[] readStreamAsByteArray(InputStream stream) throws IOException
stream
- the stream to be read
IOException
public static byte[] readFileOrPluginResourceAsByteArray(String pluginid, String resource)
resource
. If not successful the data
is read from the plug-in specified by pluginid
.
pluginid
- the plug-in id for reading from a plug-inresource
- the resource path specifying either the file or the resource identifier
null
if neither a matching
file or a matching resource could be foundpublic static InputStream getFileOrPluginResourceStream(String pluginid, String resource)
resource
. If the file does not
exist an input stream to the bundled resource from the plug-in specified by pluginid
is created.
pluginid
- the plug-in id for reading from a plug-inresource
- the resource path specifying either the file or the resource identifier
null
if neither a matching
file or a matching resource could be foundpublic static InputStream getResourceStream(String pluginid, String resource) throws IOException
pluginid
- id of the plug-in the resource is bundled withresource
- path to the resource within this plug-in
IOException
- if the specified resource could not be found
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |