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:jp.terasoluna.fw.web.taglib.WriteCodeCountTag.java

/**
 * ^O]Jn?\bh?B//from  w w  w .  ja  v a2 s  . c  o  m
 *
 * <p>
 *   T?[ubgReLXgR?[hXg??[_?[
 * ??AR?[hXg???AR?[hXgvf?
 * p?B
 * R?[hXg???A0???B
 * </p>
 *
 * @return ???w?B? <code>EVAL_BODY_INCLUDE</code>
 * @throws JspException <code>JSP</code>O
 */
@Override
public int doStartTag() throws JspException {
    if (log.isDebugEnabled()) {
        log.debug("doStartTag() called.");
    }

    JspWriter out = pageContext.getOut();

    try {
        if ("".equals(id)) {
            // id???
            log.error("id is required.");
            throw new JspTagException("id is required.");
        }

        // pageContext?AApplicationContext?B
        ServletContext sc = pageContext.getServletContext();
        ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);

        CodeListLoader loader = null;

        try {
            loader = (CodeListLoader) context.getBean(id);
        } catch (ClassCastException e) {
            //BeanCodeListLoaderOX??[
            String errorMessage = "bean id:" + id + " is not instance of CodeListLoader.";
            log.error(errorMessage);
            throw new JspTagException(errorMessage, e);
        }

        // ?P?[
        Locale locale = RequestUtils.getUserLocale((HttpServletRequest) pageContext.getRequest(),
                Globals.LOCALE_KEY);

        CodeBean[] codeBeanList = loader.getCodeBeans(locale);
        if (codeBeanList == null) {
            // codeBeanListnull??0?o?B
            if (log.isWarnEnabled()) {
                log.warn("Codebean is null. CodeListLoader(bean id:" + id + ")");
            }
            out.print(0);
        } else {
            // ????R?[hXg?o?B
            out.print(codeBeanList.length);
        }

        return EVAL_BODY_INCLUDE;
    } catch (IOException ioe) {
        log.error("IOException caused.");
        throw new JspTagException(ioe.toString());
    }
}

From source file:com.redhat.topicindex.security.FedoraAccountSystem.java

public boolean login() throws LoginException {
    if (callbackHandler == null)
        throw new LoginException("No CallbackHandler available");

    NameCallback nameCallback = new NameCallback("Username");
    PasswordCallback passwordCallback = new PasswordCallback("Password", false);

    Callback[] callbacks = new Callback[] { nameCallback, passwordCallback };

    try {//w  ww .  j av  a  2  s. co  m
        callbackHandler.handle(callbacks);

        username = nameCallback.getName();
        password = passwordCallback.getPassword();
        passwordCallback.clearPassword();
    } catch (IOException e) {
        throw new LoginException(e.toString());
    } catch (UnsupportedCallbackException e) {
        throw new LoginException("Error: " + e.getCallback().toString() + "not available");
    }

    if (authenticate()) {
        loginSucceeded = true;
    } else {
        return false;
    }

    return true;
}

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

private void doImportAndVerify(boolean isDirect, String[] expectedResults) throws IOException {

    Path warehousePath = new Path(this.getWarehouseDir());
    Path tablePath = new Path(warehousePath, TABLE_NAME);

    Path filePath;/*from  ww w.  jav a2  s  .  com*/
    if (isDirect) {
        filePath = new Path(tablePath, "data-00000");
    } else {
        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);
    }

    String[] argv = getArgv(isDirect);
    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, 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:com.orange.datavenue.client.common.ApiInvoker.java

/**
 *
 * @param out/*from  ww  w. j ava  2 s.c om*/
 * @param body
 */
private void writeStream(OutputStream out, String body) {
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
    try {
        writer.write(body);
        writer.close();
    } catch (IOException e) {
        System.out.println(e.toString());
    }
}

From source file:io.vertx.lang.js.JSVerticleFactory.java

private boolean hasNodeModules(URL url) {
    JarEntry modules = null;//from w w w.j av a  2 s.com
    try {
        modules = ClasspathFileResolver.getJarEntry(url, "node_modules");
    } catch (IOException ex) {
        log.warn(ex.toString());
        return false;
    }
    return modules != null && (modules.isDirectory() || modules.getSize() == 0);
}

From source file:io.agi.core.ml.supervised.Svm.java

/**
 * Serialise the model into a string and return.
 * @return The model as a string./*from w ww . ja v  a2s.  c o  m*/
 * @throws Exception
 */
private String modelString() throws Exception {

    String modelString = null;

    if (_model != null) {
        try {
            File modelFile = new File(MODEL_FILENAME);
            svm.svm_save_model(MODEL_FILENAME, _model);
            modelString = FileUtils.readFileToString(modelFile);
        } catch (IOException e) {
            _logger.error("Unable to save svm model.");
            _logger.error(e.toString(), e);
        }
    } else {
        String errorMessage = "Cannot to save svm model before it is defined";
        _logger.error(errorMessage);
        throw new Exception(errorMessage);
    }

    return modelString;
}

From source file:TcpClient.java

/** Default constructor. */
public TcpServer()
{
    this.payload = new TcpPayload();
    initServerSocket();/*from  ww w .  j ava2 s  . co  m*/
    try
    {
        while (true)
        {
            // listen for and accept a client connection to serverSocket
            Socket sock = this.serverSocket.accept();
            OutputStream oStream = sock.getOutputStream();
            ObjectOutputStream ooStream = new ObjectOutputStream(oStream);
            ooStream.writeObject(this.payload);  // send serilized payload
            ooStream.close();
            Thread.sleep(1000);
        }
    }
    catch (SecurityException se)
    {
        System.err.println("Unable to get host address due to security.");
        System.err.println(se.toString());
        System.exit(1);
    }
    catch (IOException ioe)
    {
        System.err.println("Unable to read data from an open socket.");
        System.err.println(ioe.toString());
        System.exit(1);
    }
    catch (InterruptedException ie) { }  // Thread sleep interrupted
    finally
    {
        try
        {
            this.serverSocket.close();
        }
        catch (IOException ioe)
        {
            System.err.println("Unable to close an open socket.");
            System.err.println(ioe.toString());
            System.exit(1);
        }
    }
}

From source file:com.provenance.cloudprovenance.storagecontroller.persistence.traceability.test.TraceabilityDBTest.java

public void addResourceTest() {

    logger.info("********************************** Create/add resource ********************");

    String serviceId = "ConfidenShare";
    String traceabilityType = "ServiceTraceability";
    String resourceType = "XMLResource";

    File traceabilityFile = new File(traceabilityFileId);

    BufferedWriter writer;/*  w  ww  .j a  va 2 s  .c  o  m*/
    try {
        writer = new BufferedWriter(new FileWriter(traceabilityFile));

        writer.write(templateData());
        writer.close();

        service.addTraceabilityResource(serviceId, traceabilityType, traceabilityFileId, traceabilityFile,
                resourceType);

    } catch (IOException e) {
        Assert.fail(e.toString());
        e.printStackTrace();
    } catch (XMLDBException e) {
        Assert.fail(e.toString());
        e.printStackTrace();
    } catch (URISyntaxException e) {
        Assert.fail(e.toString());
        e.printStackTrace();
    }
}

From source file:com.mdsh.test.media.encoding.process.AbstractProcess.java

/**
 * Internally creates the command line to execute and executes it.
 * @return the executing process/*www  .j  av  a 2 s  .c o m*/
 * @throws IOException when the process could not be executed
 */
protected synchronized Process openProcess() throws IOException {
    if (null != getProcess())
        throw new IOException("process is already created");

    // create local copy of params and prepend the executable name
    final List<String> params = new ArrayList<String>(1 + getParams().size());
    params.add(getExecutable());
    params.addAll(getParams());

    // log complete command line
    getLogger().info("execute command line: {}", paramsToString(params));

    // create process
    Process process;
    try {
        process = Runtime.getRuntime().exec(params.toArray(new String[params.size()]));
    } catch (final IOException e) {
        final String error = "could not start process: " + getExecutable() + " - " + e.toString();
        getLogger().warn(error, e);
        throw new IOException(error, e);
    }

    setProcess(process);

    return process;
}

From source file:com.alibaba.wasp.master.ActiveMasterManager.java

public void stop() {
    try {//from  w  ww .j a v  a 2s.com
        // If our address is in ZK, delete it on our way out
        ServerName activeMaster = null;
        try {
            activeMaster = MasterAddressTracker.getMasterAddress(this.watcher);
        } catch (IOException e) {
            LOG.warn("Failed get of master address: " + e.toString());
        }
        if (activeMaster != null && activeMaster.equals(this.sn)) {
            ZKUtil.deleteNode(watcher, watcher.getMasterAddressZNode());
            // We may have failed to delete the znode at the previous step, but
            // we delete the file anyway: a second attempt to delete the znode is
            // likely to fail again.
            ZNodeClearer.deleteMyEphemeralNodeOnDisk();
        }
    } catch (KeeperException e) {
        LOG.error(this.watcher.prefix("Error deleting our own master address node"), e);
    }
}