Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.msu.cme.rdp.graph.sandbox.BloomFilterInterrogator.java

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("USAGE: BloomFilterStats <bloom_filter>");
        System.exit(1);//  w ww . ja  va  2  s .c o  m
    }

    File bloomFile = new File(args[0]);

    ObjectInputStream ois = ois = new ObjectInputStream(
            new BufferedInputStream(new FileInputStream(bloomFile)));
    BloomFilter filter = (BloomFilter) ois.readObject();
    ois.close();

    printStats(filter, System.out);

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String line;
    CodonWalker walker = null;
    while ((line = reader.readLine()) != null) {
        char[] kmer = line.toCharArray();
        System.out.print(line + "\t");
        try {
            walker = filter.new RightCodonFacade(kmer);
            walker.jumpTo(kmer);
            System.out.print("present");
        } catch (Exception e) {
            System.out.print("not present\t" + e.getMessage());
        }
        System.out.println();
    }
}

From source file:com.floragunn.searchguard.tools.Hasher.java

public static void main(final String[] args) {

    final Options options = new Options();
    final HelpFormatter formatter = new HelpFormatter();
    options.addOption(/*from w ww.  j  a  v  a 2  s .  c o m*/
            Option.builder("p").argName("password").hasArg().desc("Cleartext password to hash").build());
    options.addOption(Option.builder("env").argName("name environment variable").hasArg()
            .desc("name environment variable to read password from").build());

    final CommandLineParser parser = new DefaultParser();
    try {
        final CommandLine line = parser.parse(options, args);

        if (line.hasOption("p")) {
            System.out.println(hash(line.getOptionValue("p").getBytes("UTF-8")));
        } else if (line.hasOption("env")) {
            final String pwd = System.getenv(line.getOptionValue("env"));
            if (pwd == null || pwd.isEmpty()) {
                throw new Exception("No environment variable '" + line.getOptionValue("env") + "' set");
            }
            System.out.println(hash(pwd.getBytes("UTF-8")));
        } else {
            final Console console = System.console();
            if (console == null) {
                throw new Exception("Cannot allocate a console");
            }
            final char[] passwd = console.readPassword("[%s]", "Password:");
            System.out.println(hash(new String(passwd).getBytes("UTF-8")));
        }
    } catch (final Exception exp) {
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
        formatter.printHelp("hasher.sh", options, true);
        System.exit(-1);
    }
}

From source file:edu.gmu.isa681.client.Main.java

public static void main(String[] args) {
    log.info("Setting look and feel...");

    try {//from  w  w w  .j  av a 2 s.  co m
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }

    } catch (Exception ex1) {
        log.warn(ex1.getMessage(), ex1);
        log.warn("Nimbus is not available.");
        log.warn("Switching to system look and feel");
        log.warn("Some GUI discrepancies may occur!");

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex2) {
            log.error(ex2.getMessage(), ex2);
            log.error("Could not setup a look and feel.");
            System.exit(1);
        }
    }

    log.info("Initializing GUI...");

    final JFrame frame = new JFrame();
    frame.setTitle("GoForward");
    frame.setBackground(new Color(0, 100, 0));
    UIManager.put("nimbusBase", new Color(0, 100, 0));
    //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0));
    UIManager.put("control", new Color(0, 100, 0));

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            frame.setPreferredSize(frame.getSize());
        }
    });

    Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    if (dim.width < 1366) {
        frame.setPreferredSize(new Dimension(800, 600));
    } else {
        frame.setPreferredSize(new Dimension(1200, 700));
    }

    //frame.setResizable(false);
    frame.setLocationByPlatform(true);
    frame.pack();

    Client client = new Client("localhost", Constants.SERVER_PORT);
    Controller controller = new Controller(client, frame);
    controller.applicationStarted();

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    log.info("Started");
}

From source file:client.lib.Client.java

/**
 * @param args the command line arguments
 *//*from  w ww.  j  a  v a  2s . c  o  m*/
public static void main(String[] args) {
    try {
        Client client = new Client();
        client.test("https://ametrics.it.uc3m.es/start/win");

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:luceneindexer.Main.java

/**
 * @param args the command line arguments
 *///from  ww w . ja  va 2  s. c  o  m
public static void main(String[] args) {
    // TODO code application logic here
    System.out.println("Hello world");
    //Open the file of JSON for reading
    FileOpener fOpener = new FileOpener("parks.json");

    //Create the object for writing
    LuceneWriter luceneWriter = new LuceneWriter("indexDir");

    //This is from Jackson which allows for binding the JSON to the Park.java class
    ObjectMapper objectMapper = new ObjectMapper();

    try {

        //first see if we can open a directory for writing
        if (luceneWriter.openIndex()) {
            //get a buffered reader handle to the file
            BufferedReader breader = new BufferedReader(fOpener.getFileForReading());
            String value = null;
            //loop through the file line by line and parse 
            while ((value = breader.readLine()) != null) {
                Park park = objectMapper.readValue(value, Park.class);

                //now submit each park to the lucene writer to add to the index
                luceneWriter.addPark(park);

            }

        } else {
            System.out.println("We had a problem opening the directory for writing");
        }

    } catch (Exception e) {
        System.out.println("Threw exception " + e.getClass() + " :: " + e.getMessage());
    } finally {
        //close out the index and release the lock on the file
        luceneWriter.finish();
    }

}

From source file:course.quiz.QuizTest.java

public static void main(String[] args) {
    QuizTest quizTest = null;/* w w w . jav  a2s.  c o  m*/
    try {
        quizTest = new QuizTest();
        if (false) {
            quizTest.initQuiz();
        }
        quizTest.test();
    } catch (Exception e) {
        log.error("Error in QuizTest.main: " + e.getMessage());
    } finally {
        quizTest.end();
    }
}

From source file:spatialluceneindexer.Main.java

/**
 * @param args the command line arguments
 *///from  w  w w  .  j  a va  2 s. co m
public static void main(String[] args) {

    System.out.println("Starting to create the index");

    //Open the file of JSON for reading
    FileOpener fOpener = new FileOpener("parks.json");

    //Create the object for writing
    LuceneWriter luceneWriter = new LuceneWriter("indexDir");

    //This is from Jackson which allows for binding the JSON to the Park.java class
    ObjectMapper objectMapper = new ObjectMapper();

    try {

        //first see if we can open a directory for writing
        if (luceneWriter.openIndex()) {
            //get a buffered reader handle to the file
            BufferedReader breader = new BufferedReader(fOpener.getFileForReading());
            String value = null;
            //loop through the file line by line and parse 
            while ((value = breader.readLine()) != null) {
                Park park = objectMapper.readValue(value, Park.class);

                //now submit each park to the lucene writer to add to the index
                luceneWriter.addPark(park);

            }

        } else {
            System.out.println("We had a problem opening the directory for writing");
        }

    } catch (Exception e) {
        System.out.println("Threw exception " + e.getClass() + " :: " + e.getMessage());
    } finally {
        luceneWriter.finish();
    }

    System.out.println("Finished created the index");
}

From source file:com.aerospike.hadoop.sampledata.SampleData.java

public static void main(String[] args) {

    try {//from  w w w  . ja v a  2s. c  om
        log.info("starting");
        run(args);
        log.info("finished");
    } catch (Exception ex) {

        log.error(ex.getMessage());
        ex.printStackTrace();
    }
}

From source file:cacheservice.CacheServer.java

/**
 * @param args the command line arguments
 *//*from   www .j  a  v  a  2  s.  c  o m*/
public static void main(String[] args) {
    // COMUNICACIN CON EL CLIENTE
    ServerSocket serverSocket;
    Socket socketCliente;
    DataInputStream in; //Flujo de datos de entrada
    DataOutputStream out; //Flujo de datos de salida
    String mensaje;
    int laTengoenCache = 0;

    //COMUNICACIN CON EL INDEX
    ServerSocket serverSocketIndex;
    Socket socketIndex;
    DataOutputStream outIndex;
    ObjectInputStream inIndex;
    String mensajeIndex;

    try {
        serverSocket = new ServerSocket(4444);
        System.out.print("SERVIDOR CACHE ACTIVO a la espera de peticiones");

        //MIENTRAS PERMANEZCA ACTIVO EL SERVIDOR CACHE ESPERAR? POR PETICIONES DE LOS CLIENTES
        while (true) {
            socketCliente = serverSocket.accept();
            in = new DataInputStream(socketCliente.getInputStream()); //Entrada de los mensajes del cliente
            mensaje = in.readUTF(); //Leo el mensaje enviado por el cliente

            System.out.println("\nHe recibido del cliente: " + mensaje); //Muestro el mensaje recibido por el cliente
            //int particionBuscada = seleccionarParticion(mensaje, tamanoCache, numeroParticiones); //Busco la particin
            //double tamanoParticion = Math.ceil( (double)tamanoCache / (double)numeroParticiones);

            //Thread hilo = new Hilo(mensaje,particionBuscada,cache.GetTable(),(int) tamanoParticion);
            //hilo.start();

            //RESPUESTA DEL SERVIDOR CACHE AL CLIENTE
            out = new DataOutputStream(socketCliente.getOutputStream());
            String respuesta = "Respuesta para " + mensaje;
            if (laTengoenCache == 1) {
                out.writeUTF(respuesta);
                System.out.println("\nTengo la respuesta. He respondido al cliente: " + respuesta);
            } else {
                out.writeUTF("miss");
                out.close();
                in.close();
                socketCliente.close();

                System.out.println("\nNo tengo la respuesta.");

                //LEER RESPUESTA DEL SERVIDOR INDEX
                serverSocketIndex = new ServerSocket(6666);
                socketIndex = serverSocketIndex.accept();
                inIndex = new ObjectInputStream(socketIndex.getInputStream());
                JSONObject mensajeRecibidoIndex = (JSONObject) inIndex.readObject();

                System.out.println("He recibido del SERVIDOR INDEX: " + mensajeRecibidoIndex);

                //outIndex.close();
                inIndex.close();
                socketIndex.close();

            }

        }
    } catch (Exception e) {
        System.out.print(e.getMessage());
    }
}

From source file:edu.lternet.pasta.datapackagemanager.ArchiveCleaner.java

/**
 * @param args/*w  ww  .ja v a2  s  . c o  m*/
 */
public static void main(String[] args) {

    ArchiveCleaner ac = null;

    try {
        ac = new ArchiveCleaner();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }

    ac.doClean(60000L);

}