Example usage for java.io IOException getMessage

List of usage examples for java.io IOException getMessage

Introduction

In this page you can find the example usage for java.io IOException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:LiteralPDF.java

/**
 * @param args//w ww.j  a  va2s.  c  om
 */
public static void main(String[] args) {

    System.out.println("Literal PDF Syntax");
    Document.compress = false;

    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LiteralPDF.pdf"));

        // step 3: we open the document
        document.open();

        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();
        String star = "0.3 g\n15.000 27.000 m\n" + "7.947 5.292 l\n26.413 18.708 l\n"
                + "3.587 18.708 l\n22.053 5.292 l\nf\n" + "45.000 57.000 m\n37.947 35.292 l\n"
                + "56.413 48.708 l\n33.587 48.708 l\n" + "52.053 35.292 l\nf\n" + "0.7 g\n15.000 57.000 m\n"
                + "7.947 35.292 l\n26.413 48.708 l\n" + "3.587 48.708 l\n22.053 35.292 l\nf\n"
                + "45.000 27.000 m\n37.947 5.292 l\n" + "56.413 18.708 l\n33.587 18.708 l\n"
                + "52.053 5.292 l\nf";
        cb.setLiteral(star);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
}

From source file:gomokuserver.GomokuServer.java

/**
 * @param args the command line arguments
 * @throws java.lang.InterruptedException
 *///  w ww .j  a v  a 2s .  com
public static void main(String[] args) throws InterruptedException {
    if (args.length != 1) {
        System.out.println("Run with listen portno as argument");
        return;
    }

    int portno = Integer.parseInt(args[0]);
    ServerSocket sc;
    try {
        System.out.print("Creating socket bound to " + portno + " ... ");
        sc = new ServerSocket(portno);

        System.out.println("DONE");
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
        return;
    }
    FrontOffice fo = new FrontOffice();
    Lobby lb = new Lobby();
    fo.setReferalLobby(lb);
    fo.start();
    lb.start();
    while (!interrupted()) {
        try {
            Socket playersocket = sc.accept();
            playersocket.setKeepAlive(true);
            System.out.println("Received client from " + playersocket.getInetAddress());
            fo.handle(playersocket);
        } catch (IOException ex) {
            Logger.getLogger(GomokuServer.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    fo.interrupt();
    lb.interrupt();
    fo.join();
    lb.join();
}

From source file:edu.usd.btl.ontology.ToolTree.java

public static void main(String[] args) throws Exception {
    try {/*  w  w  w .  ja v a 2  s.  com*/
        //File ontoInput = new File(".\\ontology_files\\EDAM_1.3.owl");
        ObjectMapper mapper = new ObjectMapper();
        OntologyFileRead ontFileRead = new OntologyFileRead();
        ArrayList<edu.usd.btl.ontology.BioPortalElement> nodeList = ontFileRead
                .readFile(".\\ontology_files\\EDAM_1.3.owl");
        //write nodelist to JSON string
        ObjectWriter treeWriter = mapper.writer().withDefaultPrettyPrinter();
        String edamJSON = mapper.writeValueAsString(nodeList);

        JsonNode rootNode = mapper.readValue(edamJSON, JsonNode.class);
        System.out.println("IsNull" + rootNode.toString());

        OntSearch ontSearch = new OntSearch();
        System.out.println(nodeList.get(0).getURI());
        String result = ontSearch.searchElementByURI("http://edamontology.org/topic_2817");
        System.out.println("RESULT = " + result);

        String topicSearchResult = ontSearch.findAllTopics();
        System.out.println("Topics Result = " + topicSearchResult);

        File ontFile = new File(".\\ontology_files\\EDAM_1.3.owl");
        String searchFromFileResult = ontSearch.searchNodeFromFile("http://edamontology.org/topic_2817",
                ".\\ontology_files\\EDAM_1.3.owl");
        System.out.println("File Response = " + searchFromFileResult.toString());
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }

    //Hashmap stuff
    //        OntologyFileRead ontFileRead = new OntologyFileRead();
    //        ArrayList<edu.usd.btl.ontology.BioPortalElement> nodeList = ontFileRead.readFile(".\\ontology_files\\EDAM_1.3.owl");
    //        
    //        HashMap hm = new HashMap();
    //        
    //        //find topics
    //        ArrayList<OntologyNode> ontoTopicList = new ArrayList();
    //        
    //        for(BioPortalElement node : nodeList){
    //            //System.out.println("****" + node.getURI());
    //            hm.put(node.getURI(), node.getName());
    //        }
    //        
    //        Set set = hm.entrySet();
    //        Iterator i = set.iterator();
    //        while(i.hasNext()){
    //            Map.Entry me = (Map.Entry)i.next();
    //            System.out.println(me.getKey() + ": " + me.getValue());
    //        }
    //        System.out.println("HashMap Size = " + hm.size());
}

From source file:com.simba.demo.airplay.srv.ElementalEchoServer.java

public static void main(String[] args) throws Exception {
    IOEventDispatch ioEventDispatch = new DefaultIoEventDispatch();
    ListeningIOReactor ioReactor = new DefaultListeningIOReactor();
    ioReactor.listen(new InetSocketAddress(8080));
    try {//from w w  w .ja  v a2s  .c  om
        ioReactor.execute(ioEventDispatch);
    } catch (InterruptedIOException ex) {
        System.err.println("Interrupted");
    } catch (IOException e) {
        System.err.println("I/O error: " + e.getMessage());
    }
    System.out.println("Shutdown");
}

From source file:example.ConfigurationsExample.java

public static void main(String[] args) {
    String jdbcPropToLoad = "prod.properties";
    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption("d", "dev", false,
            "Dev tag to launch app in dev mode. Means that app will launch embedded mckoi db.");
    try {//from w w  w .ja va  2 s.c  om
        CommandLine line = parser.parse(options, args);
        if (line.hasOption("d")) {
            System.err.println("App is in DEV mode");
            jdbcPropToLoad = "dev.properties";
        }
    } catch (ParseException exp) {
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
    }
    Properties p = new Properties();
    try {
        p.load(ConfigurationsExample.class.getResourceAsStream("/" + jdbcPropToLoad));
    } catch (IOException e) {
        System.err.println("Properties loading failed.  Reason: " + e.getMessage());
    }
    try {
        String clazz = p.getProperty("driver.class");
        Class.forName(clazz);
        System.out.println(" Jdbc driver loaded :" + clazz);
    } catch (ClassNotFoundException e) {
        System.err.println("Jdbc Driver class loading failed.  Reason: " + e.getMessage());
        e.printStackTrace();
    }

}

From source file:Main.java

public static void main(String[] args) {

    File workingDirectory = new File("C:" + File.separator + "Invoices");

    File template = new File(workingDirectory.getAbsolutePath() + File.separator + "invoiceTemplate.tex");

    File tempDir = new File(workingDirectory.getAbsolutePath() + File.separator + "temp");
    if (!tempDir.isDirectory()) {
        tempDir.mkdir();//from   www. j  a  v a 2s  .c  o  m
    }

    File invoice1 = new File(tempDir.getAbsolutePath() + File.separator + "invoice1.tex");
    File invoice2 = new File(tempDir.getAbsolutePath() + File.separator + "invoice2.tex");

    try {

        HashMap<String, String> data = new HashMap<String, String>();

        data.put("Number", "1");
        data.put("Customer name", "Ivan Pfeiffer");
        data.put("Customer street", "Schwarzer Weg 4");
        data.put("Customer zip", "13505 Berlin");
        data.put("Development", "Software");
        data.put("Price", "500");

        JLRConverter converter = new JLRConverter("::", ":::");
        if (!converter.parse(template, invoice1, data)) {
            System.out.println(converter.getErrorMessage());
        }

        data.put("Number", "2");
        data.put("Customer name", "Mike Mueller");
        data.put("Customer street", "Prenzlauer Berg 12");
        data.put("Customer zip", "10405 Berlin");
        data.put("Development", "Hardware");
        data.put("Price", "2350");

        if (!converter.parse(template, invoice2, data)) {
            System.out.println(converter.getErrorMessage());
        }

        File desktop = new File(System.getProperty("user.home") + File.separator + "Desktop");

        JLRGenerator pdfGen = new JLRGenerator();

        pdfGen.deleteTempTexFile(false);

        if (!pdfGen.generate(invoice1, desktop, workingDirectory)) {
            System.out.println(pdfGen.getErrorMessage());
        }

        JLROpener.open(pdfGen.getPDF());

        if (!pdfGen.generate(invoice2, desktop, workingDirectory)) {
            System.out.println(pdfGen.getErrorMessage());
        }

        JLROpener.open(pdfGen.getPDF());

    } catch (IOException ex) {
        System.err.println(ex.getMessage());
    }
}

From source file:FileCopy.java

/** The main() method of the standalone program. Calls copy(). */
public static void main(String[] args) {
    if (args.length != 2) // Check arguments
        System.err.println("Usage: java FileCopy <source> <destination>");
    else {//from   w  w w.j a v  a  2s.c om
        // Call copy() to do the copy; display any error messages
        try {
            copy(args[0], args[1]);
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
    }
}

From source file:edu.harvard.i2b2.Icd9ToSnomedCT.BinResourceFromIcd9ToSnomedCTMap.java

public static void main(String[] args) {

    try {//from   w w w. j  a  v a  2 s  .  co m
        new BinResourceFromIcd9ToSnomedCTMap("/Users/kbw19/Downloads/ICD9CM_SNOMEDCT_map_201512/");
    } catch (IOException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        logger.error(e.getMessage(), e);
    }
}

From source file:edu.unc.lib.dl.util.Checksum.java

public static void main(String[] args) {
    for (int i = 0; i < args.length; i++) {
        File file = new File(args[i]);
        Checksum checker = new Checksum();
        System.out.print(args[i]);
        System.out.print(":");
        try {/*from  w  w  w .  java 2 s . c o m*/
            System.out.print(checker.getChecksum(file));
        } catch (IOException e) {
            System.out.print(e.getMessage());
        }

    }
}

From source file:com.myjeeva.poi.demo.Excel2JavaDemo.java

/**
 * @param args/*from w w  w  . j  av a2 s.co m*/
 * @throws FileNotFoundException
 */
public static void main(String[] args) throws FileNotFoundException {
    String SAMPLE_PERSON_DATA_FILE_PATH = "src/main/resources/Sample-Person-Data.xlsx";

    // Input File initialize
    File file = new File(SAMPLE_PERSON_DATA_FILE_PATH);
    InputStream inputStream = new FileInputStream(file);

    // Excel Cell Mapping
    Map<String, String> cellMapping = new HashMap<String, String>();
    cellMapping.put("HEADER", "Person Id,Name,Height,Email Address,DOB,Salary");
    cellMapping.put("A", "personId");
    cellMapping.put("B", "name");
    cellMapping.put("C", "height");
    cellMapping.put("D", "emailId");
    cellMapping.put("E", "dob");
    cellMapping.put("F", "salary");

    // The package open is instantaneous, as it should be.
    OPCPackage pkg = null;
    try {

        ExcelWorkSheetHandler<PersonVO> workSheetHandler = new ExcelWorkSheetHandler<PersonVO>(PersonVO.class,
                cellMapping);

        pkg = OPCPackage.open(inputStream);
        ExcelReader excelReader = new ExcelReader(pkg, workSheetHandler);
        excelReader.process();

        if (workSheetHandler.getValueList().isEmpty()) {
            // No data present
            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandler.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            // Displaying data ead from Excel file
            displayPersonList(workSheetHandler.getValueList());
        }

    } catch (RuntimeException are) {
        LOG.error(are.getMessage(), are.getCause());
    } catch (InvalidFormatException ife) {
        LOG.error(ife.getMessage(), ife.getCause());
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } finally {
        IOUtils.closeQuietly(inputStream);
        try {
            if (null != pkg) {
                pkg.close();
            }
        } catch (IOException e) {
            // just ignore IO exception
        }
    }
}