All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truevfs.samples.raes.Application Maven / Gradle / Ivy

Go to download

Sample applications to demonstrate the usage of TrueVFS modules to support many, even esoteric use cases.

There is a newer version: 0.14.0
Show newest version
/*
 * Copyright (C) 2005-2013 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truevfs.samples.raes;

import java.io.IOException;
import static java.lang.System.*;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;

/**
 * @author Christian Schlichtherle
 */
public abstract class Application {

    String message(String key, Object... args) {
        return String.format(
                ResourceBundle.getBundle(getClass().getName()).getString(key),
                args);
    }

    int run(final String[] args) throws IOException {
        try {
            runChecked(args);
        } catch (IllegalArgumentException | NoSuchElementException ex) {
            String message = ex.getLocalizedMessage();
            if (null == message) message = message("usage", getClass().getSimpleName());
            err.println(message);
            return 2;
        } catch (Exception ex) {
            ex.printStackTrace();
            return 1;
        }
        return 0;
    }

    abstract void runChecked(String[] args) throws IOException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy