28 import java.nio.file.StandardCopyOption;
29
30 /**
31 * Dump a class file for a class on the class path in the current directory
32 */
33 public class ClassFileInstaller {
34 /**
35 * @param args The names of the classes to dump
36 * @throws Exception
37 */
38 public static void main(String... args) throws Exception {
39 for (String arg : args) {
40 ClassLoader cl = ClassFileInstaller.class.getClassLoader();
41
42 // Convert dotted class name to a path to a class file
43 String pathName = arg.replace('.', '/').concat(".class");
44 InputStream is = cl.getResourceAsStream(pathName);
45
46 // Create the class file's package directory
47 Path p = Paths.get(pathName);
48 Files.createDirectories(p.getParent());
49 // Create the class file
50 Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
51 }
52 }
53 }
|
28 import java.nio.file.StandardCopyOption;
29
30 /**
31 * Dump a class file for a class on the class path in the current directory
32 */
33 public class ClassFileInstaller {
34 /**
35 * @param args The names of the classes to dump
36 * @throws Exception
37 */
38 public static void main(String... args) throws Exception {
39 for (String arg : args) {
40 ClassLoader cl = ClassFileInstaller.class.getClassLoader();
41
42 // Convert dotted class name to a path to a class file
43 String pathName = arg.replace('.', '/').concat(".class");
44 InputStream is = cl.getResourceAsStream(pathName);
45
46 // Create the class file's package directory
47 Path p = Paths.get(pathName);
48 Path parent = p.getParent();
49 if (parent != null) {
50 Files.createDirectories(parent);
51 }
52 // Create the class file
53 Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
54 }
55 }
56 }
|