Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.xtensive.plugins.pdfviewer.PDFViewer.java

/**
 * Display a MuPDF from the specified asset path.
 *
 * @param path           The path to load.
 * @return               "" if ok, or error message.
 */// w  w  w  . j  av  a  2s.c o  m

private String openAsset(String path) {

    InputStream input;

    String filePath = "";
    String result = "";

    try {
        String filename = path.substring(path.lastIndexOf("/") + 1, path.length());

        input = cordova.getActivity().getApplicationContext().getAssets().open(path);

        // Don't copy the file if it already exists
        File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename);
        if (!fp.exists()) {
            this.copy(input, filename);
        }

        // change uri to be to the new file in internal storage
        filePath = FILE_PREFIX + this.cordova.getActivity().getFilesDir() + "/" + filename;

        result = this.openPDF(filePath);

        return result;

    } catch (IOException e) {

        e.printStackTrace();
        Log.e(LOG_TAG, "Error loading asset " + path + ": " + e.toString());

        return e.toString();

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

        return e.toString();
    }
}

From source file:org.callimachusproject.server.helpers.Exchange.java

@Override
public synchronized boolean cancel() {
    cancelled = true;/*from   w w w.j  ava 2 s  . com*/
    closeRequest();
    if (response != null) {
        consume(response);
    }
    if (producer != null) {
        try {
            producer.close();
        } catch (IOException e) {
            logger.debug(e.toString(), e);
        }
    }
    return false;
}

From source file:org.f3.tools.framework.Reporter.java

private void printTimingReport() {
    HtmlWriter timingReport = null;//from   ww  w  .  j  a  v a  2  s  .  c om
    HtmlWriter dashboardTimingReport = null;
    try {
        timingReport = new HtmlWriter(TIMING_RESULT_FILE_NAME, detailsTable("Timing in milliseconds"));
        dashboardTimingReport = new HtmlWriter("timing-dashboard.html", dashboardTable("Timing"));
        Set<String> kset = new TreeSet<String>(result.keySet());
        for (String x : kset) {
            Float currentToGoal = percentChangeTiming(goals, result, x);
            Float currentToLast = percentChangeTiming(last, result, x);
            // print to details table
            timingReport.writeToHtmlTable(nameAsHref(x), getPerformanceValue(result12, x),
                    getPerformanceValue(result13, x), getPerformanceValue(goals, x),
                    getPerformanceValue(last, x), getPerformanceValue(result, x), currentToGoal.toString(),
                    currentToLast.toString());

            // generate images and print to dashboard
            dashboardTimingReport.writeToHtmlTable(nameAsHref(x),
                    generateImage(TIMING_RESULT_FILE_NAME, x + TIMING_GOAL_PLOT_FILE_NAME_TAIL, currentToGoal),
                    generateImage(TIMING_RESULT_FILE_NAME, x + TIMING_LAST_PLOT_FILE_NAME_TAIL, currentToLast));
        }
    } catch (IOException ioe) {
        Utils.logger.severe(ioe.toString());
    } finally {
        Utils.close(dashboardTimingReport);
        Utils.close(timingReport);
    }
}

From source file:com.cloudera.sqoop.manager.DB2ManagerImportManualTest.java

private void runDb2Test(String[] expectedResults) throws IOException {

    Path warehousePath = new Path(this.getWarehouseDir());
    Path tablePath = new Path(warehousePath, getTableName());
    Path filePath = new Path(tablePath, "part-m-00000");

    File tableFile = new File(tablePath.toString());
    if (tableFile.exists() && tableFile.isDirectory()) {
        // remove the directory before running the import.
        FileListing.recursiveDeleteDir(tableFile);
    }//ww  w  .j av  a 2 s . co m

    String[] argv = getArgv();
    try {
        runImport(argv);
    } catch (IOException ioe) {
        LOG.error("Got IOException during import: " + ioe.toString());
        ioe.printStackTrace();
        fail(ioe.toString());
    }

    File f = new File(filePath.toString());
    assertTrue("Could not find imported data file", f.exists());
    BufferedReader r = null;
    try {
        // Read through the file and make sure it's all there.
        r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
        for (String expectedLine : expectedResults) {
            assertEquals(expectedLine, r.readLine());
        }
    } catch (IOException ioe) {
        LOG.error("Got IOException verifying results: " + ioe.toString());
        ioe.printStackTrace();
        fail(ioe.toString());
    } finally {
        IOUtils.closeStream(r);
    }
}

From source file:org.f3.tools.framework.Reporter.java

private void printHeapReport() {
    HtmlWriter footprintReport = null;/*from   ww w. j  a v a 2 s  .  c  o m*/
    HtmlWriter dashboardFootprintReport = null;
    try {
        footprintReport = new HtmlWriter(FOOTPRINT_RESULT_FILE_NAME, detailsTable("Footprint in MBytes"));
        dashboardFootprintReport = new HtmlWriter("footprint-dashboard.html", dashboardTable("Footprint"));

        Set<String> kset = new TreeSet<String>(result.keySet());
        for (String x : kset) {
            Float currentToGoal = percentChangeHeap(goals, result, x);
            Float currentToLast = percentChangeHeap(last, result, x);
            footprintReport.writeToHtmlTable(nameAsHref(x), getHeapsizeValue(result12, x),
                    getHeapsizeValue(result13, x), getHeapsizeValue(goals, x), getHeapsizeValue(last, x),
                    getHeapsizeValue(result, x), currentToGoal.toString(), currentToLast.toString());

            // generate images and print to dashboard
            dashboardFootprintReport.writeToHtmlTable(nameAsHref(x),
                    generateImage(FOOTPRINT_RESULT_FILE_NAME, x + FOOTPRINT_GOAL_PLOT_FILE_NAME_TAIL,
                            currentToGoal),
                    generateImage(FOOTPRINT_RESULT_FILE_NAME, x + FOOTPRINT_LAST_PLOT_FILE_NAME_TAIL,
                            currentToLast));
        }
    } catch (IOException ioe) {
        Utils.logger.severe(ioe.toString());
    } finally {
        Utils.close(footprintReport);
        Utils.close(dashboardFootprintReport);
    }
}

From source file:org.matsim.counts.algorithms.graphs.helper.OutputDelegate.java

private void writeHtml(final CountsGraph cg, final String iter_path, boolean indexFile) {
    /* we want landscape, thus exchange width / height */
    int width = 800;
    int height = 600;

    JFreeChart chart = null;/*from w w w.j a v a2  s  .  com*/
    String fileName = "";
    File file2;
    if (!indexFile) {
        chart = cg.getChart();
        fileName = cg.getFilename();
        file2 = new File(iter_path + "/" + fileName + ".html");
    } else {
        file2 = new File(iter_path + "/start.html");
    }

    PrintWriter writer = null;
    try {
        ChartRenderingInfo info = null;
        File file1;
        if (!indexFile) {
            info = new ChartRenderingInfo(new StandardEntityCollection());
            file1 = new File(iter_path + "/png/" + fileName + ".png");
            ChartUtilities.saveChartAsPNG(file1, chart, width, height, info);
        }

        writer = new PrintWriter(new BufferedOutputStream(new FileOutputStream(file2)));

        writer.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        //writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">");
        writer.println(
                "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
        writer.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
        writer.println("<head>");
        //writer.println("<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\" />");
        writer.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
        writer.println("<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\"/>");
        writer.println("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"/>");

        writer.println("<title> MATSim validation </title>");
        writer.println("<script type=\"text/javascript\" src=\"div/overlib.js\"></script>");
        writer.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"div/style1.css\"/>");
        writer.println("</head>");
        writer.println("<body>");

        writer.println("<div id=\"overDiv\" style=\"Z-INDEX: 1; POSITION: absolute\"></div>");

        writer.println("<div id=\"header\">");
        writer.println("<div id=\"logo\">");
        writer.println(
                "<img src=\"div/logo.png\" width=\"224\" height=\"52\" style=\"border:none;\" alt=\"logo\"/><br>Multi-Agent Transport Simulation Toolkit");
        writer.println("</div>");
        writer.println("<h3>Counting Volumes</h3>");
        writer.println("</div>");

        writer.println("<div id=\"footer\">");

        GregorianCalendar cal = new GregorianCalendar();
        writer.println(cal.get(Calendar.DATE) + ".");
        writer.println(cal.get(Calendar.MONTH) + 1 + ".");
        writer.println(cal.get(Calendar.YEAR) + "\t ");
        writer.println(System.getProperty("user.name"));

        writer.println("</div>");
        writer.println("<div id=\"links\">");

        for (Section sec : this.sections_) {
            writer.print("<h3>");
            writer.print(sec.getTitle() + ":<br />");
            writer.print("</h3>");

            Iterator<MyURL> url_it = sec.getURLs().iterator();
            while (url_it.hasNext()) {
                MyURL url = url_it.next();
                writer.println("<a href=\"" + url.address + "\">" + url.displayText + "</a><br />");
            }
        }
        writer.println("</div>");

        writer.println("<div id=\"contents\">");
        writer.println("<p>");
        if (!indexFile) {
            ChartUtilities.writeImageMap(writer, "chart", info, true);

            /*
              chart=cg.getChart();
              CategoryPlot plot=chart.getCategoryPlot();
            Renderer renderer=(BarRenderer) plot.getRenderer();
            renderer.getSeriesToolTipGenerator(0);
             */

            /*   how to get tooltips in there, without using xxxToolTipTagFragmentGenerator?
                 Wait for next version of jFreeChart? Meanwhile doing slight changes to the libarary
                 String imagemap=ChartUtilities.getImageMap("chart", info);
                 System.out.println(imagemap);
             */

            // reference '#chart' not working without '#'
            writer.println("<img src=\"png/" + fileName + ".png\" " + "width=\"" + width + "\" height=\""
                    + height + "\" style=\"border:none;\" alt=\"graph\" usemap=\"#chart\"/>");
        } else {
            writer.println("<img src=\"div/title.png\" "
                    + "width=\"972\" height=\"602\" style=\"border:none;\" alt=\"title\"/>");
        }
        writer.println("</p>");
        writer.println("</div>");
        writer.println("</body>");
        writer.println("</html>");

    } catch (IOException e) {
        System.out.println(e.toString());
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
}

From source file:com.cloudera.sqoop.manager.CubridManagerImportTest.java

private void doImportAndVerify(String tableName, String[] expectedResults, String... extraArgs)
        throws IOException {
    Path warehousePath = new Path(this.getWarehouseDir());
    Path tablePath = new Path(warehousePath, tableName);
    Path filePath = new Path(tablePath, "part-m-00000");

    File tableFile = new File(tablePath.toString());
    if (tableFile.exists() && tableFile.isDirectory()) {
        // remove the directory before running the import.
        FileListing.recursiveDeleteDir(tableFile);
    }//from  w w  w  .j av a 2  s .  co m

    String[] argv = getArgv(tableName, extraArgs);
    try {
        runImport(argv);
    } catch (IOException ioe) {
        LOG.error("Got IOException during import: " + ioe.toString());
        ioe.printStackTrace();
        fail(ioe.toString());
    }

    File f = new File(filePath.toString());
    assertTrue("Could not find imported data file", f.exists());
    BufferedReader r = null;
    try {
        // Read through the file and make sure it's all there.
        r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
        for (String expectedLine : expectedResults) {
            assertEquals(expectedLine, r.readLine());
        }
    } catch (IOException ioe) {
        LOG.error("Got IOException verifying results: " + ioe.toString());
        ioe.printStackTrace();
        fail(ioe.toString());
    } finally {
        IOUtils.closeStream(r);
    }
}

From source file:org.wikipedia.nirvana.nirvanabot.BotReporter.java

public void reportTXT(String fileName) {
    if (timeFinished == null) {
        timeFinished = Calendar.getInstance();
    }//  w  w w .j av a  2  s.com
    if (!fileName.endsWith(".txt")) {
        fileName = fileName + ".txt";
    }
    log.info("generating report (TXT) . . .");
    StringBuilder sb = new StringBuilder();
    //StringBuffer sbuf = new StringBuffer();
    sb.append(ReportItem.getHeaderTXT()).append("\r\n");
    for (ReportItem item : reportItems) {
        sb.append(item.toStringTXT());
        sb.append("\r\n");
    }
    sb.append(ReportItem.getFooterTXT());
    try {
        FileTools.writeFile(sb.toString(), fileName);
    } catch (IOException e) {
        log.error(e.toString());
        e.printStackTrace();
    }
    log.info("report is generated!");
}

From source file:com.phoenixnap.oss.ramlapisync.plugin.SpringMvcRamlApiSyncMojo.java

public void execute() throws MojoExecutionException, MojoFailureException {
    long startTime = System.currentTimeMillis();
    if (project.getPackaging().equals("pom")) {
        this.getLog().info("Skipping [pom] project: " + project.getName());

    } else if (project.getPackaging().equals("maven-plugin")) {
        this.getLog().info("Skipping [maven-plugin] project: " + project.getName());

    } else if (!Files.isDirectory(Paths.get(project.getBuild().getSourceDirectory()),
            LinkOption.NOFOLLOW_LINKS)) {
        this.getLog().info("Skipping project with missing src folder: " + project.getName());

    } else {/*from   www.  ja va 2  s . c  om*/
        try {
            generateRaml();
        } catch (IOException e) {
            ClassLoaderUtils.restoreOriginalClassLoader();
            throw new MojoExecutionException(e, "Unexpected exception while executing Raml Sync Plugin.",
                    e.toString());
        }
    }
    this.getLog().info("Raml Generation Complete in:" + (System.currentTimeMillis() - startTime) + "ms");
}

From source file:com.apporiented.hermesftp.server.impl.ServerRFC959Test.java

/**
 * Test case: change file date.//from   w w w .  j  a  v  a 2s.  co  m
 */
@Test
public void testTouch() {
    String str;
    try {
        getClient().storeText(testFile, testText);
        getClient().sendAndReceive("MDTM 19800202111111 " + testFile);
        getClient().list(testFile);
        str = getClient().getTextData();
        assertTrue(str.indexOf("Feb 02 11:11") > 0);
        getClient().sendAndReceive("DELE " + testFile);
    } catch (IOException e) {
        log.error(e);
        fail(e.toString());
    }
}