Example usage for java.io File getCanonicalFile

List of usage examples for java.io File getCanonicalFile

Introduction

In this page you can find the example usage for java.io File getCanonicalFile.

Prototype

public File getCanonicalFile() throws IOException 

Source Link

Document

Returns the canonical form of this abstract pathname.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    // create new files
    File f = new File("test.txt");

    File path = f.getCanonicalFile();

    System.out.print("Absolute Pathname " + path);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    File file1 = new File("./filename");
    File file2 = new File("filename");
    System.out.println(file1.equals(file2));

    file1 = file1.getCanonicalFile();
    file2 = file2.getCanonicalFile();//from  w ww.  ja v a2  s  . c o  m
    System.out.println(file1.equals(file2));
}

From source file:org.pentaho.vfs.test.VfsBrowserTest.java

public static void main(String args[]) {
    FileSystemManager fsManager = null;//from   w w  w .jav  a2 s . c om
    FileObject rootFile = null;
    try {
        fsManager = VFS.getManager();
        if (fsManager instanceof DefaultFileSystemManager) {
            File f = new File("."); //$NON-NLS-1$
            try {
                ((DefaultFileSystemManager) fsManager).setBaseFile(f.getCanonicalFile());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        // rootFile = fsManager.resolveFile("jar:lib/jdom.jar2");
        // rootFile = fsManager.resolveFile("file:/home/mdamour/workspace/apache-vfs-browser");
        rootFile = fsManager.resolveFile("file:///"); //$NON-NLS-1$
    } catch (Exception e) {
        e.printStackTrace();
    }
    Shell s = new Shell();
    s.setLayout(new FillLayout());
    VfsBrowser browser = new VfsBrowser(s, SWT.MIN | SWT.MAX | SWT.CLOSE | SWT.RESIZE, rootFile, null, false,
            false);
    s.setVisible(true);
    while (!s.isDisposed()) {
        try {
            if (!s.getDisplay().readAndDispatch())
                s.getDisplay().sleep();
        } catch (SWTException e) {
        }
    }
}

From source file:org.red5.server.Standalone.java

/**
 * Main entry point for the Red5 Server usage java Standalone
 * //from  www.j av  a  2s  .co  m
 * @param args
 *            String passed in that points to a red5.xml config file
  * @throws Throwable            Base type of all exceptions
 */
public static void main(String[] args) throws Throwable {

    //System.setProperty("DEBUG", "true");

    /*
    if (false) {
       allocator = new DebugPooledByteBufferAllocator(true);
       ByteBuffer.setAllocator(allocator);
    }
    */

    if (args.length == 1) {
        red5Config = args[0];
    }

    long time = System.currentTimeMillis();

    log.info("RED5 Server (http://www.osflash.org/red5)");
    log.info("Loading red5 global context from: " + red5Config);

    // Detect root of Red5 configuration and set as system property
    String root;
    String classpath = System.getProperty("java.class.path");
    File fp = new File(red5Config);
    fp = fp.getCanonicalFile();
    if (!fp.isFile()) {
        // Given file does not exist, search it on the classpath
        String[] paths = classpath.split(System.getProperty("path.separator"));
        for (String element : paths) {
            fp = new File(element + '/' + red5Config);
            fp = fp.getCanonicalFile();
            if (fp.isFile()) {
                break;
            }
        }
    }

    if (!fp.isFile()) {
        throw new Exception(
                "could not find configuration file " + red5Config + " on your classpath " + classpath);
    }

    root = fp.getAbsolutePath();
    root = root.replace('\\', '/');
    int idx = root.lastIndexOf('/');
    root = root.substring(0, idx);
    System.setProperty("red5.config_root", root);
    log.info("Setting configuation root to " + root);

    // Setup system properties so they can be evaluated by Jetty
    Properties props = new Properties();

    // Load properties
    props.load(new FileInputStream(root + "/red5.properties"));

    for (Object o : props.keySet()) {
        String key = (String) o;
        if (key != null && !key.equals("")) {
            System.setProperty(key, props.getProperty(key));
        }
    }

    // Store root directory of Red5
    idx = root.lastIndexOf('/');
    root = root.substring(0, idx);
    if (System.getProperty("file.separator").equals("/")) {
        // Workaround for linux systems
        root = '/' + root;
    }

    // Set Red5 root as environment variable
    System.setProperty("red5.root", root);
    log.info("Setting Red5 root to " + root);

    System.setProperty("red5.webapp.root", root + "/webapps/");
    log.info("Setting webapp root to " + root);

    try {
        ContextSingletonBeanFactoryLocator.getInstance(red5Config).useBeanFactory("red5.common");
    } catch (Exception e) {
        // Don't raise wrapped exceptions as their stacktraces may confuse
        // people...
        raiseOriginalException(e);
    }

    long startupIn = System.currentTimeMillis() - time;
    log.info("Startup done in: " + startupIn + " ms");

}

From source file:com.khubla.jvmbasic.jvmbasicc.JVMBasic.java

/**
 * start here//from w ww  .  j  a v  a2s .c  om
 * <p>
 * -file src\test\resources\bas\easy\print.bas -verbose true
 * </p>
 */
public static void main(String[] args) {
    try {
        System.out.println("khubla.com jvmBASIC Compiler");
        /*
         * options
         */
        final Options options = new Options();
        Option oo = Option.builder().argName(OUTPUT_OPTION).longOpt(OUTPUT_OPTION).type(String.class).hasArg()
                .required(false).desc("target directory to output to").build();
        options.addOption(oo);
        oo = Option.builder().argName(FILE_OPTION).longOpt(FILE_OPTION).type(String.class).hasArg()
                .required(true).desc("file to compile").build();
        options.addOption(oo);
        oo = Option.builder().argName(VERBOSE_OPTION).longOpt(VERBOSE_OPTION).type(String.class).hasArg()
                .required(false).desc("verbose output").build();
        options.addOption(oo);
        /*
         * parse
         */
        final CommandLineParser parser = new DefaultParser();
        CommandLine cmd = null;
        try {
            cmd = parser.parse(options, args);
        } catch (final Exception e) {
            e.printStackTrace();
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("posix", options);
            System.exit(0);
        }
        /*
         * verbose output?
         */
        final Boolean verbose = Boolean.parseBoolean(cmd.getOptionValue(VERBOSE_OPTION));
        /*
         * get the file
         */
        final String filename = cmd.getOptionValue(FILE_OPTION);
        final String outputDirectory = cmd.getOptionValue(OUTPUT_OPTION);
        if (null != filename) {
            /*
             * filename
             */
            final String basFileName = System.getProperty("user.dir") + "/" + filename;
            final File fl = new File(basFileName);
            if (true == fl.exists()) {
                /*
                 * show the filename
                 */
                System.out.println("Compiling: " + fl.getCanonicalFile());
                /*
                 * compiler
                 */
                final JVMBasicCompiler jvmBasicCompiler = new JVMBasicCompiler();
                /*
                 * compile
                 */
                jvmBasicCompiler.compileToClassfile(basFileName, null, outputDirectory, verbose, true, true);
            } else {
                throw new Exception("Unable to find: '" + basFileName + "'");
            }
        } else {
            throw new Exception("File was not supplied");
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}

From source file:iaj.linkit.App.java

/**
 * Application entry method./*w ww . j ava  2 s. c o  m*/
 *
 * @param args Command line arguments.
 */
public static void main(final String[] args) {
    final Configuration config = new Configuration();
    final CmdLineParser parser = new CmdLineParser(config);

    try {
        parser.parseArgument(args);

        final File f = (config.getPaths().size() > 0) ? new File(config.getPaths().get(0)).getCanonicalFile()
                : new File(DIR_CURRENT).getCanonicalFile();
        if (!f.exists()) {
            System.err.println("No such path: " + f.getCanonicalFile());
            System.exit(1);
        } else if (!f.canRead()) {
            System.err.println("Can't read path.");
            System.exit(1);
        } else if (f.isDirectory()) {
            handleFiles(config.isRecursive(), f.listFiles());
        } else {
            handleFiles(config.isRecursive(), f);
        }

    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (final CmdLineException e) {
        System.err.println(e.getMessage());
        System.err.println("lu [options...] [paths...]"); //$NON-NLS-1$
        parser.printUsage(System.err);
        System.exit(1);
    }
}

From source file:org.pentaho.vfs.test.FileChooserTest.java

public static void main(String args[]) {
    FileSystemManager fsManager = null;//from w ww .ja  va  2  s . c  o m
    FileObject maybeRootFile = null;
    try {
        fsManager = VFS.getManager();
        if (fsManager instanceof DefaultFileSystemManager) {
            File f = new File("."); //$NON-NLS-1$
            try {
                ((DefaultFileSystemManager) fsManager).setBaseFile(f.getCanonicalFile());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //maybeRootFile = fsManager.resolveFile("jar:lib/mail-1.3.2.jar"); //$NON-NLS-1$
        // rootFile = fsManager.resolveFile("file:/home/mdamour/workspace/apache-vfs-browser");
        maybeRootFile = fsManager.resolveFile("file:///c:/");
        // maybeRootFile = fsManager.resolveFile("jar:lib/mail.jar");
        // maybeRootFile = fsManager.resolveFile("ftp://ftpgolden.pentaho.org/");

        // maybeRootFile.getFileSystem().getParentLayer().

        // maybeRootFile.getFileSystem().getFileSystemManager().gets

    } catch (Exception e) {
        e.printStackTrace();
    }
    final FileObject rootFile = maybeRootFile;
    final Shell applicationShell = new Shell(SWT.SHELL_TRIM | SWT.CLOSE | SWT.MIN | SWT.MAX);
    applicationShell.setLayout(new FillLayout());
    applicationShell.setText(Messages.getString("FileChooserTest.application")); //$NON-NLS-1$
    applicationShell.setSize(640, 400);
    Menu bar = new Menu(applicationShell, SWT.BAR);
    applicationShell.setMenuBar(bar);
    MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
    fileItem.setText(Messages.getString("FileChooserTest.file")); //$NON-NLS-1$
    fileItem.setAccelerator(SWT.CTRL + 'F');
    Menu fileSubMenu = new Menu(applicationShell, SWT.DROP_DOWN);
    fileItem.setMenu(fileSubMenu);
    MenuItem fileOpenItem = new MenuItem(fileSubMenu, SWT.CASCADE);
    fileOpenItem.setText(Messages.getString("FileChooserTest.open")); //$NON-NLS-1$
    fileOpenItem.setAccelerator(SWT.CTRL + 'O');
    final String filters[] = new String[] { "*.*", "*.xml;*.XML;", "*.class", "*.map" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    final String filterNames[] = new String[] { Messages.getString("FileChooserTest.allFiles"), //$NON-NLS-1$
            Messages.getString("FileChooserTest.xmlFiles"), Messages.getString("FileChooserTest.javaFiles"), //$NON-NLS-1$//$NON-NLS-2$
            Messages.getString("FileChooserTest.mapFiles") }; //$NON-NLS-1$
    fileOpenItem.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }

        public void widgetSelected(SelectionEvent arg0) {
            FileObject initialFile = rootFile;
            // try {
            // // initialFile = rootFile.resolveFile("/home/mdamour");
            // } catch (FileSystemException e) {
            // e.printStackTrace();
            // }
            try {
                VfsFileChooserDialog fileOpenDialog = new VfsFileChooserDialog(applicationShell,
                        VFS.getManager(), rootFile, initialFile);
                fileOpenDialog.addVFSUIPanel(buildHDFSPanel("HDFS", fileOpenDialog));
                fileOpenDialog.addVFSUIPanel(buildHDFSPanel("S3", fileOpenDialog));
                fileOpenDialog.addVFSUIPanel(buildHDFSPanel("file", fileOpenDialog));
                FileObject selectedFile = fileOpenDialog.open(applicationShell, null, filters, filterNames,
                        VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
                if (selectedFile != null) {
                    System.out.println(
                            Messages.getString("FileChooserTest.selectedFileEquals") + selectedFile.getName()); //$NON-NLS-1$
                } else {
                    System.out.println(Messages.getString("FileChooserTest.noFileSelected")); //$NON-NLS-1$
                }
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });
    MenuItem saveAsOpenItem = new MenuItem(fileSubMenu, SWT.CASCADE);
    saveAsOpenItem.setText(Messages.getString("FileChooserTest.saveAs")); //$NON-NLS-1$
    saveAsOpenItem.setAccelerator(SWT.CTRL + 'A');
    saveAsOpenItem.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent arg0) {
        }

        public void widgetSelected(SelectionEvent arg0) {
            FileObject initialFile = null;
            try {
                initialFile = rootFile.resolveFile("/home/mdamour"); //$NON-NLS-1$
            } catch (FileSystemException e) {
                e.printStackTrace();
            }
            try {
                VfsFileChooserDialog fileOpenDialog = new VfsFileChooserDialog(applicationShell,
                        VFS.getManager(), rootFile, initialFile);
                FileObject selectedFile = fileOpenDialog.open(applicationShell,
                        Messages.getString("FileChooserTest.untitled"), filters, filterNames, //$NON-NLS-1$
                        VfsFileChooserDialog.VFS_DIALOG_SAVEAS);
                if (selectedFile != null) {
                    System.out.println(
                            Messages.getString("FileChooserTest.selectedFileEquals") + selectedFile.getName()); //$NON-NLS-1$
                } else {
                    System.out.println(Messages.getString("FileChooserTest.noFileSelected")); //$NON-NLS-1$
                }
            } catch (FileSystemException ex) {
                ex.printStackTrace();
            }
        }
    });
    applicationShell.open();
    while (!applicationShell.isDisposed()) {
        if (!applicationShell.getDisplay().readAndDispatch())
            applicationShell.getDisplay().sleep();
    }
}

From source file:org.nuxeo.runtime.deployment.preprocessor.PackZip.java

public static void main(String[] args)
        throws IOException, ConfigurationException, ParserConfigurationException, SAXException {
    if (args.length < 2) {
        fail("Usage: PackZip nuxeo_ear_directory target_directory [order]");
    }/*from  w  w w . j a va2  s .  c  o m*/
    String v = args[0];
    File ear = new File(v);
    if (!ear.isDirectory()) {
        fail("Invalid build - no exploded nuxeo.ear found at " + ear.getAbsolutePath());
    }
    v = args[1];
    File target = new File(v);
    ear = ear.getCanonicalFile();
    target = target.getCanonicalFile();
    if (target.exists()) {
        FileUtils.deleteDirectory(target);
    }
    target.mkdirs();
    if (!target.isDirectory()) {
        fail("Invalid target directory: " + v + ". Not a directory or directory could not be created");
    }

    log.info("Packing nuxeo.ear at " + ear.getAbsolutePath() + " into " + target.getAbsolutePath());

    PackZip pack = new PackZip(ear, target);
    if (args.length >= 3) {
        pack.execute(args[2]);
    } else {
        pack.execute(null);
    }
}

From source file:org.opendatakit.appengine.updater.UpdaterWindow.java

/**
 * Launch the application.//from  w  w w  .  j  ava2s .  co  m
 */
public static void main(String[] args) {

    translations = ResourceBundle.getBundle(TranslatedStrings.class.getCanonicalName(), Locale.getDefault());

    Options options = addOptions();

    // get location of this jar
    String reflectedJarPath = UpdaterWindow.class.getProtectionDomain().getCodeSource().getLocation().getFile();
    // remove %20 substitutions.
    reflectedJarPath = reflectedJarPath.replace("%20", " ");
    File myJar = new File(reflectedJarPath, Preferences.JAR_NAME);
    System.out.println("CodeSource Location: " + myJar.getAbsolutePath());
    File cleanJarPath = null;
    if (myJar.exists()) {
        try {
            cleanJarPath = myJar.getCanonicalFile();
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
    if (cleanJarPath == null) {
        // try finding this within our working directory
        String dir = System.getProperty("user.dir");
        if (dir != null) {
            File myWD = new File(dir);
            if (myWD.exists()) {
                myJar = new File(myWD, Preferences.JAR_NAME);
                System.out.println("user.dir path: " + myJar.getAbsolutePath());
                if (myJar.exists()) {
                    try {
                        cleanJarPath = myJar.getCanonicalFile();
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }
        }
    }

    if (cleanJarPath != null) {
        myJarDir = cleanJarPath.getParentFile();
        System.out.println(fmt(TranslatedStrings.DIR_RUNNABLE_JAR, myJarDir.getAbsolutePath()));
    } else {
        myJarDir = null;
    }

    CommandLineParser parser = new DefaultParser();
    final CommandLine cmdArgs;

    try {
        cmdArgs = parser.parse(options, args);
    } catch (ParseException e1) {
        System.out.println(fmt(TranslatedStrings.LAUNCH_FAILED, e1.getMessage()));
        showHelp(options);
        System.exit(1);
        return;
    }

    if (cmdArgs.hasOption(ArgumentNameConstants.HELP)) {
        showHelp(options);
        System.exit(0);
        return;
    }

    if (cmdArgs.hasOption(ArgumentNameConstants.VERSION)) {
        showVersion();
        System.exit(0);
        return;
    }

    if (myJarDir == null && !cmdArgs.hasOption(ArgumentNameConstants.INSTALL_ROOT)) {
        System.out.println(fmt(TranslatedStrings.INSTALL_ROOT_REQUIRED, Preferences.JAR_NAME,
                ArgumentNameConstants.INSTALL_ROOT));
        showHelp(options);
        System.exit(1);
        return;
    }

    // required for all operations
    if (cmdArgs.hasOption(ArgumentNameConstants.NO_UI) && !cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) {
        System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED, ArgumentNameConstants.EMAIL));
        showHelp(options);
        System.exit(1);
        return;
    }

    // update appEngine with the local configuration
    if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) {

        if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) {
            System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.UPLOAD,
                    ArgumentNameConstants.CLEAR));
        }

        if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) {
            System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.UPLOAD,
                    ArgumentNameConstants.ROLLBACK));
        }

        if (!cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) {
            System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED_CMD, ArgumentNameConstants.EMAIL));
        }
        showHelp(options);
        System.exit(1);
        return;
    }

    // rollback any stuck outstanding configuration transaction on appEngine infrastructure
    if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) {

        if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) {
            System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.ROLLBACK,
                    ArgumentNameConstants.CLEAR));
        }

        if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) {
            System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.ROLLBACK,
                    ArgumentNameConstants.UPLOAD));
        }

        if (!cmdArgs.hasOption(ArgumentNameConstants.EMAIL)) {
            System.out.println(fmt(TranslatedStrings.ARG_IS_REQUIRED_CMD, ArgumentNameConstants.EMAIL));
        }
        showHelp(options);
        System.exit(1);
        return;
    }

    if (cmdArgs.hasOption(ArgumentNameConstants.CLEAR)) {

        if (cmdArgs.hasOption(ArgumentNameConstants.ROLLBACK)) {
            System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.CLEAR,
                    ArgumentNameConstants.ROLLBACK));
        }

        if (cmdArgs.hasOption(ArgumentNameConstants.UPLOAD)) {
            System.out.println(fmt(TranslatedStrings.CONFLICTING_ARGS_CMD, ArgumentNameConstants.CLEAR,
                    ArgumentNameConstants.UPLOAD));
        }
        showHelp(options);
        System.exit(1);
        return;
    }

    if (!cmdArgs.hasOption(ArgumentNameConstants.NO_UI)) {

        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    // Set System L&F
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

                    UpdaterWindow window = new UpdaterWindow(cmdArgs);
                    window.frame.setTitle(fmt(TranslatedStrings.AGG_INSTALLER_VERSION, Preferences.VERSION));
                    ImageIcon icon = new ImageIcon(
                            UpdaterWindow.class.getClassLoader().getResource("odkupdater.png"));
                    window.frame.setIconImage(icon.getImage());
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    } else {

        try {

            UpdaterCLI aggregateInstallerCLI = new UpdaterCLI(cmdArgs);
            aggregateInstallerCLI.run();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:org.springframework.data.keyvalue.riak.util.RiakClassFileLoader.java

public static void main(String[] args) {
    Parser p = new BasicParser();
    CommandLine cl = null;//from www .  j  a  v  a  2  s .c om
    try {
        cl = p.parse(opts, args);
    } catch (ParseException e) {
        System.err.println("Error parsing command line: " + e.getMessage());
    }

    if (null != cl) {
        boolean verbose = cl.hasOption('v');
        RiakTemplate riak = new RiakTemplate();
        riak.getRestTemplate().setErrorHandler(new Ignore404sErrorHandler());
        if (cl.hasOption('u')) {
            riak.setDefaultUri(cl.getOptionValue('u'));
        }
        try {
            riak.afterPropertiesSet();
        } catch (Exception e) {
            System.err.println("Error creating RiakTemplate: " + e.getMessage());
        }
        String[] files = cl.getOptionValues('j');
        if (null != files) {
            for (String file : files) {
                if (verbose) {
                    System.out.println(String.format("Loading JAR file %s into Riak...", file));
                }
                try {
                    File zfile = new File(file);
                    ZipInputStream zin = new ZipInputStream(new FileInputStream(zfile));
                    ZipEntry entry;
                    while (null != (entry = zin.getNextEntry())) {
                        ByteArrayOutputStream bout = new ByteArrayOutputStream();
                        byte[] buff = new byte[16384];
                        for (int bytesRead = zin.read(buff); bytesRead > 0; bytesRead = zin.read(buff)) {
                            bout.write(buff, 0, bytesRead);
                        }

                        if (entry.getName().endsWith(".class")) {
                            String name = entry.getName().replaceAll("/", ".");
                            name = URLEncoder.encode(name.substring(0, name.length() - 6), "UTF-8");
                            String bucket;
                            if (cl.hasOption('b')) {
                                bucket = cl.getOptionValue('b');
                            } else {
                                bucket = URLEncoder.encode(zfile.getCanonicalFile().getName(), "UTF-8");
                            }
                            if (verbose) {
                                System.out.println(String.format("Uploading to %s/%s", bucket, name));
                            }

                            // Load these bytes into Riak
                            riak.setAsBytes(bucket, name, bout.toByteArray());
                        }
                    }
                } catch (FileNotFoundException e) {
                    System.err.println("Error reading JAR file: " + e.getMessage());
                } catch (IOException e) {
                    System.err.println("Error reading JAR file: " + e.getMessage());
                }
            }
        }

        String[] classFiles = cl.getOptionValues('c');
        if (null != classFiles) {
            for (String classFile : classFiles) {
                try {
                    FileInputStream fin = new FileInputStream(classFile);
                    ByteArrayOutputStream bout = new ByteArrayOutputStream();
                    byte[] buff = new byte[16384];
                    for (int bytesRead = fin.read(buff); bytesRead > 0; bytesRead = fin.read(buff)) {
                        bout.write(buff, 0, bytesRead);
                    }

                    String name;
                    if (cl.hasOption('k')) {
                        name = cl.getOptionValue('k');
                    } else {
                        throw new IllegalStateException(
                                "Must specify a Riak key in which to store the data if loading individual class files.");
                    }
                    String bucket;
                    if (cl.hasOption('b')) {
                        bucket = cl.getOptionValue('b');
                    } else {
                        throw new IllegalStateException(
                                "Must specify a Riak bucket in which to store the data if loading individual class files.");
                    }
                    if (verbose) {
                        System.out.println(String.format("Uploading to %s/%s", bucket, name));
                    }

                    // Load these bytes into Riak
                    riak.setAsBytes(bucket, name, bout.toByteArray());

                } catch (FileNotFoundException e) {
                    System.err.println("Error reading class file: " + e.getMessage());
                } catch (IOException e) {
                    System.err.println("Error reading class file: " + e.getMessage());
                }
            }
        }
    }
}