Package org.cyclos.server.utils
Class ResourceHelper
- java.lang.Object
-
- org.cyclos.server.utils.ResourceHelper
-
public class ResourceHelper extends Object
Helper for acquiring resources
-
-
Constructor Summary
Constructors Constructor Description ResourceHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetFullName(String parent, String resource)Returns the full path name for this resource, handling nullsstatic StringgetName(String resource)Returns the unqualified resource namestatic StringgetParentName(String resource)Returns the name of the parent resource, or empty string if no separator is found on the resource namestatic URLgetResource(String resource)Returns a resource using the current thread's class loaderstatic longgetSize(String resource)Returns the resource size, handling files and jar file entriesstatic List<String>listResources(String path)Returns a list of resources according to the class path or file resources, optionally recursivestatic ReaderopenReader(String resource)Opens a class path resource as a readerstatic InputStreamopenStream(String resource)Opens a class path resource as an input streamstatic byte[]readBytes(String resource)Reads the content of the given resource, returning the bytes, or null if not foundstatic StringreadContent(String resource)Reads the content of the given resource, returning the string, or null if not found
-
-
-
Method Detail
-
getFullName
public static String getFullName(String parent, String resource)
Returns the full path name for this resource, handling nulls
-
getParentName
public static String getParentName(String resource)
Returns the name of the parent resource, or empty string if no separator is found on the resource name
-
getResource
public static URL getResource(String resource)
Returns a resource using the current thread's class loader
-
getSize
public static long getSize(String resource)
Returns the resource size, handling files and jar file entries
-
listResources
public static List<String> listResources(String path)
Returns a list of resources according to the class path or file resources, optionally recursive
-
openReader
public static Reader openReader(String resource) throws IOException
Opens a class path resource as a reader- Throws:
IOException
-
openStream
public static InputStream openStream(String resource) throws IOException
Opens a class path resource as an input stream- Throws:
IOException
-
readBytes
public static byte[] readBytes(String resource) throws IOException
Reads the content of the given resource, returning the bytes, or null if not found- Throws:
IOException
-
readContent
public static String readContent(String resource) throws IOException
Reads the content of the given resource, returning the string, or null if not found- Throws:
IOException
-
-