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.moz.fiji.schema.impl.hbase.HBaseSchemaTable.java

/**
 * Deletes an HBase table.//from w  w  w.j  a v  a2s  . c  o  m
 *
 * @param admin HBase admin client.
 * @param tableName Name of the table to delete.
 */
private static void deleteTable(HBaseAdmin admin, String tableName) {
    try {
        if (admin.tableExists(tableName)) {
            if (admin.isTableEnabled(tableName)) {
                admin.disableTable(tableName);
            }
            admin.deleteTable(tableName);
        }
    } catch (IOException ioe) {
        LOG.error(String.format("Unable to delete table '%s': %s", tableName, ioe.toString()));
    }
}

From source file:it.evilsocket.dsploit.core.System.java

public static boolean isForwardingEnabled() {
    boolean forwarding = false;
    BufferedReader reader;//from ww  w .j  a v a 2s  .  com
    String line;

    try {
        reader = new BufferedReader(new FileReader(IPV4_FORWARD_FILEPATH));
        line = reader.readLine().trim();
        forwarding = line.equals("1");

        reader.close();

    } catch (IOException e) {
        Log.w(TAG, e.toString());
    }

    return forwarding;
}

From source file:it.evilsocket.dsploit.core.System.java

public static synchronized void errorLog(String tag, String data) {
    String filename = (new File(Environment.getExternalStorageDirectory().toString(), ERROR_LOG_FILENAME))
            .getAbsolutePath();//from   w  w  w.  j a v a  2s.  co m

    data = data.trim();

    if (mContext != null && getSettings().getBoolean("PREF_DEBUG_ERROR_LOGGING", false) == true) {
        try {
            FileWriter fWriter = new FileWriter(filename, true);
            BufferedWriter bWriter = new BufferedWriter(fWriter);

            bWriter.write(data);

            bWriter.close();
        } catch (IOException ioe) {
            Log.e(TAG, ioe.toString());
        }
    }

    Log.e(tag, data);
}

From source file:com.yunmel.syncretic.utils.io.IOUtils.java

public static void fileWrite(final String fileName, final String contents) {
    checkNotNull(fileName, "Provided file name for writing must NOT be null.");
    checkNotNull(contents, "Unable to write null contents.");
    final File newFile = new File(fileName);
    try {//from   ww w .  j a  v  a2s  . c om
        Files.write(contents.getBytes("utf-8"), newFile);
    } catch (IOException fileIoEx) {
        err.println("ERROR trying to write to file '" + fileName + "' - " + fileIoEx.toString());
    }
}

From source file:ProgressMeterStrmDemo.java

/** We use a separate "thread" (see Threads chapter) to do the reading,
 * so the GUI can run independantly (since we have "sleep" calls to make
 * it appear to run more slowly)./*from   ww w .  j a  v  a  2  s. c o m*/
 */
public void run() {
    try {
        readTheFile();
    } catch (EOFException nme) {
        return;
    } catch (IOException e) {
        System.err.println(e.toString());
        return;
    }
}

From source file:ListOfNumbers2.java

public void readList(String fileName) {
    String line = null;/*ww w  . j  a va2s.c  om*/
    try {
        RandomAccessFile raf = new RandomAccessFile(fileName, "r");
        while ((line = raf.readLine()) != null) {
            Integer i = new Integer(Integer.parseInt(line));
            System.out.println(i);
            victor.addElement(i);
        }
    } catch (FileNotFoundException fnf) {
        System.err.println("File: " + fileName + " not found.");
    } catch (IOException io) {
        System.err.println(io.toString());
    }
}

From source file:it.evilsocket.dsploit.core.System.java

public static synchronized void errorLogging(String tag, Exception e) {
    String message = "Unknown error.", trace = "Unknown trace.",
            filename = (new File(Environment.getExternalStorageDirectory().toString(), ERROR_LOG_FILENAME))
                    .getAbsolutePath();/*from w w w  . ja  v a 2  s.co m*/

    if (e != null) {
        if (e.getMessage() != null && e.getMessage().isEmpty() == false)
            message = e.getMessage();

        else if (e.toString() != null)
            message = e.toString();

        Writer sWriter = new StringWriter();
        PrintWriter pWriter = new PrintWriter(sWriter);

        e.printStackTrace(pWriter);

        trace = sWriter.toString();

        if (mContext != null && getSettings().getBoolean("PREF_DEBUG_ERROR_LOGGING", false) == true) {
            try {
                FileWriter fWriter = new FileWriter(filename, true);
                BufferedWriter bWriter = new BufferedWriter(fWriter);

                bWriter.write(trace);

                bWriter.close();
            } catch (IOException ioe) {
                Log.e(TAG, ioe.toString());
            }
        }
    }

    setLastError(message);
    Log.e(tag, message);
    Log.e(tag, trace);
}

From source file:net.longfalcon.newsj.nntp.NntpConnectionFactory.java

public NewsClient getNntpClient() {
    NewsClient nntpClient = null;/*  w  ww  .j  a  v a2s. c om*/
    try {
        nntpClient = new CustomNNTPClient();
        int port = Integer.parseInt(config.getNntpPort());
        nntpClient.connect(config.getNntpServer(), port);
        nntpClient.authenticate(config.getNntpUserName(), config.getNntpPassword());
        nntpClient.setKeepAlive(true);
    } catch (IOException e) {
        _log.error(e.toString(), e);
    }

    return nntpClient;
}

From source file:com.computationnode.Summator.java

@POST
@Consumes(MediaType.APPLICATION_JSON)//  ww w .j  a  va  2  s.  c o  m
@Produces(MediaType.APPLICATION_JSON)
public Response sum(String inputValues) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    String responseString = new String();
    try {
        Double[] inputArray = mapper.readValue(inputValues, Double[].class);
        double result = 0;
        for (int i = 0; i < inputArray.length; ++i) {
            result += inputArray[i];
        }
        responseString = "[" + result + "]";
    } catch (IOException e) {
        return Response.serverError().entity(e.toString()).build();
    }
    return Response.ok(responseString, MediaType.APPLICATION_JSON).build();
}

From source file:pt.unl.fct.di.novalincs.yanux.scavenger.common.logging.JsonFileLogger.java

@Override
public void open() throws IOException {
    super.open();
    try {/*from w ww . j  a  v  a  2s  .co  m*/
        logFile = mapper.readValue(file, LogFile.class);
    } catch (IOException e) {
        Log.e(LOG_TAG, e.toString());
        logFile = new LogFile(filename);
    }
    //Add new session
    currentLogSession = new LogSession();
    logFile.getSessions().add(currentLogSession);
}