4358N/A/*
4358N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4358N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4358N/A *
4358N/A * This code is free software; you can redistribute it and/or modify it
4358N/A * under the terms of the GNU General Public License version 2 only, as
4358N/A * published by the Free Software Foundation.
4358N/A *
4358N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4358N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4358N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4358N/A * version 2 for more details (a copy is included in the LICENSE file that
4358N/A * accompanied this code).
4358N/A *
4358N/A * You should have received a copy of the GNU General Public License version
4358N/A * 2 along with this work; if not, write to the Free Software Foundation,
4358N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4358N/A *
4358N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4358N/A * or visit www.oracle.com if you need additional information or have any
4358N/A * questions.
4358N/A */
4358N/A
4358N/Aimport java.io.InputStream;
4358N/Aimport java.nio.file.Files;
4358N/Aimport java.nio.file.Path;
4358N/Aimport java.nio.file.Paths;
4358N/Aimport java.nio.file.StandardCopyOption;
4358N/A
4358N/A/**
4358N/A * Dump a class file for a class on the class path in the current directory
4358N/A */
4358N/Apublic class ClassFileInstaller {
4358N/A /**
4358N/A * @param args The names of the classes to dump
4358N/A * @throws Exception
4358N/A */
4358N/A public static void main(String... args) throws Exception {
4358N/A for (String arg : args) {
4358N/A ClassLoader cl = ClassFileInstaller.class.getClassLoader();
4358N/A
4358N/A // Convert dotted class name to a path to a class file
4358N/A String pathName = arg.replace('.', '/').concat(".class");
4358N/A InputStream is = cl.getResourceAsStream(pathName);
4358N/A
4358N/A // Create the class file's package directory
4358N/A Path p = Paths.get(pathName);
4358N/A Files.createDirectories(p.getParent());
4358N/A // Create the class file
4358N/A Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
4358N/A }
4358N/A }
4358N/A}