Class Resource

java.lang.Object
eu.bandm.tools.util.Resource

public class Resource extends Object
Auxiliary methods and auxiliary application for dealing with "resources" in the Java sense = non-class files in a class-file tree. (The main(java.lang.String[]) application is often called by Makefiles etc.)
  • Constructor Details

    • Resource

      public Resource()
  • Method Details

    • copyToFile

      public static void copyToFile(Class<?> cl, String name, File target) throws IOException
      Extract a resource file from the classloader-world into the normal file system.
      Parameters:
      cl - the class relative to which the resource is adressed.
      name - a path relative to this class identifying the resource
      target - where to copy it.
      Throws:
      IOException
    • copyToFile

      public static void copyToFile(ClassLoader cl, String name, File target) throws IOException
      Extract a resource file from the classloader-world into the normal file system.
      Parameters:
      cl - class loader relative to which the resource is adressed.
      name - a path relative to this class identifying the resource
      target - where to copy it.
      Throws:
      IOException
    • main

      public static void main(String[] args) throws ClassNotFoundException, IOException
      Command line tool to extract a resource relative to a given class out of a class tree into the normal file system. The default class loader is used, as with a simple Class.forName(String).
       
        arg[0] = classname
        arg[1] = relative path from class to resource
        arg[2] = filename to store
        
      Throws:
      ClassNotFoundException
      IOException