< prev index next >

src/com/sun/javatest/agent/Map.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


  45  * adjusting filenames because of differences introduced by different mount points
  46  * for various file systems.
  47  * <p>
  48  * This facility has been largely superceded by the map substitution mechanism
  49  * provided by environment files.
  50  */
  51 public class Map {
  52     /**
  53      * Read a map from a specified file.  This code is deliberately
  54      * written to tolerate Java platforms without a file system ...
  55      * as in some versions of Personal Java. Any problems caused by
  56      * the file system not being present are returned as IOExceptions
  57      * with a suitable detail message.
  58      * @param name The name of the file to read
  59      * @return The map read from the given file
  60      * @throws IOException if any errors occurred reading the file
  61      */
  62     public static Map readFile(String name) throws IOException {
  63         try {
  64             Class<?> c = Class.forName("java.io.FileReader"); // optional API in Jersonal Java
  65             Constructor m = c.getConstructor(new Class[] {String.class});
  66             Reader r = (Reader)(m.newInstance(new Object[] {name}));
  67             return new Map(r);
  68         }
  69         catch (ClassNotFoundException e) {
  70             throw new IOException("file system not accessible (" + e + ")");
  71         }
  72         catch (InvocationTargetException e) {
  73             Throwable t = e.getTargetException();
  74             if (t instanceof IOException)
  75                 throw (IOException)t;
  76             else
  77                 throw fileSystemProblem(t);
  78         }
  79         catch (IllegalAccessException e) {
  80             throw fileSystemProblem(e);
  81         }
  82         catch (InstantiationException e) {
  83             throw fileSystemProblem(e);
  84         }
  85         catch (NoSuchMethodException e) {




  45  * adjusting filenames because of differences introduced by different mount points
  46  * for various file systems.
  47  * <p>
  48  * This facility has been largely superceded by the map substitution mechanism
  49  * provided by environment files.
  50  */
  51 public class Map {
  52     /**
  53      * Read a map from a specified file.  This code is deliberately
  54      * written to tolerate Java platforms without a file system ...
  55      * as in some versions of Personal Java. Any problems caused by
  56      * the file system not being present are returned as IOExceptions
  57      * with a suitable detail message.
  58      * @param name The name of the file to read
  59      * @return The map read from the given file
  60      * @throws IOException if any errors occurred reading the file
  61      */
  62     public static Map readFile(String name) throws IOException {
  63         try {
  64             Class<?> c = Class.forName("java.io.FileReader"); // optional API in Jersonal Java
  65             Constructor<?> m = c.getConstructor(new Class<?>[] {String.class});
  66             Reader r = (Reader)(m.newInstance(new Object[] {name}));
  67             return new Map(r);
  68         }
  69         catch (ClassNotFoundException e) {
  70             throw new IOException("file system not accessible (" + e + ")");
  71         }
  72         catch (InvocationTargetException e) {
  73             Throwable t = e.getTargetException();
  74             if (t instanceof IOException)
  75                 throw (IOException)t;
  76             else
  77                 throw fileSystemProblem(t);
  78         }
  79         catch (IllegalAccessException e) {
  80             throw fileSystemProblem(e);
  81         }
  82         catch (InstantiationException e) {
  83             throw fileSystemProblem(e);
  84         }
  85         catch (NoSuchMethodException e) {


< prev index next >