Example usage for java.io IOException printStackTrace

List of usage examples for java.io IOException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:examples.weatherTelnet.java

public final static void main(String[] args) {
    TelnetClient telnet;/* w ww  . j a v  a  2 s  . c o m*/

    telnet = new TelnetClient();

    try {
        telnet.connect("rainmaker.wunderground.com", 3000);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    IOUtil.readWrite(telnet.getInputStream(), telnet.getOutputStream(), System.in, System.out);

    try {
        telnet.disconnect();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    System.exit(0);
}

From source file:Main.java

public static void main(String[] args) {
    Path src = Paths.get("test.txt");
    String encoding = System.getProperty("file.encoding");
    Charset cs = Charset.forName(encoding);
    try (SeekableByteChannel seekableChannel = Files.newByteChannel(src, READ, WRITE, CREATE,
            TRUNCATE_EXISTING)) {/*from   w  w w  .ja  v  a2 s .  c o  m*/
        printDetails(seekableChannel, "Before writing data");
        writeData(seekableChannel, cs);
        printDetails(seekableChannel, "After writing data");

        seekableChannel.position(0);
        printDetails(seekableChannel, "After resetting position to 0");
        readData(seekableChannel, cs);
        printDetails(seekableChannel, "After reading data");
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.mapr.data.sputnik.JsonGenerator.java

public static void main(String... args) {
    String config = "config6.json";
    try {/*from  w  w  w  . j  av  a 2s  . c om*/
        ObjectMapper mapper = new ObjectMapper();
        JsonGenerator gen = new JsonGenerator();
        log.info("Generated json Map: " + mapper.writeValueAsString(gen.testMapGenerator(config)));
        log.info("Generated flattened json Map: " + gen.testFlatJsonGenerator(config));
        JsonGenerator gen2 = new JsonGenerator();
        log.info("Generated json List: " + gen2.testListGenerator("config3.json"));
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:contractEditor.SPConfFileEditor.java

public static void main(String[] args) {

    JSONObject obj = new JSONObject();
    ArrayList fileList = new ArrayList();

    fileList.add("confSP" + File.separator + "HOST1.json");
    fileList.add("confSP" + File.separator + "HOST2.json");
    fileList.add("confSP" + File.separator + "HOST3.json");
    fileList.add("confSP" + File.separator + "HOST4.json");

    obj.put("contract_list_of_SP", fileList);

    try {//from w w  w  . j a  v  a  2 s. c  o  m

        FileWriter file = new FileWriter("confSP" + File.separator + "contractFileList.json");
        file.write(obj.toJSONString());
        file.flush();
        file.close();

    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.print(obj);

}

From source file:de.drippinger.cytricHelper.CommandLineStart.java

public static void main(String[] args) throws ParseException {

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(createOptions(), args);

    CytricHelper helper = new CytricHelper();

    if (cmd.hasOption("f") && cmd.hasOption("e")) {
        try {/*from ww w .j av  a  2  s  . c  o m*/
            helper.manipulatePdf(cmd.getOptionValue("f"), cmd.getOptionValue("e"));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (DocumentException e) {
            e.printStackTrace();
        }
    } else {
        printHelp();
    }

}

From source file:com.rdio.simple.examples.CommandLine.java

public static void main(String[] args) throws IOException, JSONException {
    ConsumerCredentials consumerCredentials = new ConsumerCredentials();
    RdioClient rdio = new RdioCoreClient(consumerCredentials);

    try {/*from  w ww  .  j  a v  a  2 s .co m*/
        RdioClient.AuthState authState = rdio.beginAuthentication("oob");
        System.out.println("Go to: " + authState.url);
        System.out.print("Then enter the code: ");
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String verifier = reader.readLine().trim();
        RdioClient.Token accessToken = rdio.completeAuthentication(verifier, authState.requestToken);
        rdio = new RdioCoreClient(consumerCredentials, accessToken);

        try {
            JSONObject response = new JSONObject(rdio.call("getPlaylists"));
            JSONArray playlists = (JSONArray) ((JSONObject) response.get("result")).get("owned");
            for (int i = 0; i < playlists.length(); i++) {
                JSONObject playlist = playlists.getJSONObject(i);
                System.out.println(playlist.getString("shortUrl") + "\t" + playlist.getString("name"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (RdioClient.RdioException e) {
        System.err.println("Rdio Error: " + e.toString());
    }
}

From source file:org.energyos.espi.datacustodian.console.ImportUsagePoint.java

public static void main(String[] args) {
    if (args.length == 2) {
        try {/*  w  w  w  .  ja  v  a 2  s  . co  m*/
            String filename = args[0];
            String url = args[1];

            DefaultHttpClient client = new DefaultHttpClient();
            client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
            upload(filename, url, client);
            client.getConnectionManager().shutdown();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        System.out.println("Usage: import_usage_point.sh filename url");
        System.out.println("");
        System.out.println("Example:");
        System.out.println("");
        System.out.println(
                "  import_usage_point.sh etc/usage_point.xml http://localhost:8080/custodian/retailcustomers/1/upload");
    }
}

From source file:com.bright.utils.rmDuplicateLines.java

public static void main(String args) {
    File monfile = new File(args);

    Set<String> userIdSet = new LinkedHashSet<String>();

    if (monfile.isFile() && monfile.getName().endsWith(".txt")) {
        try {/*  w w w  . ja va  2s.c o m*/
            List<String> content = FileUtils.readLines(monfile, Charset.forName("UTF-8"));
            userIdSet.addAll(content);

            Iterator<String> itr = userIdSet.iterator();
            StringBuffer output = new StringBuffer();
            while (itr.hasNext()) {

                output.append(itr.next() + System.getProperty("line.separator"));

            }

            BufferedWriter out = new BufferedWriter(new FileWriter(monfile));
            String outText = output.toString();

            out.write(outText);

            out.close();
        } catch (IOException e) {
            e.printStackTrace();

        }
    }

}

From source file:EchoServer.java

public static void main(String[] args) {
    try {// w ww. j ava 2  s.c o  m
        // establish server socket
        ServerSocket s = new ServerSocket(8189);

        // wait for client connection
        Socket incoming = s.accept();
        try {
            InputStream inStream = incoming.getInputStream();
            OutputStream outStream = incoming.getOutputStream();

            Scanner in = new Scanner(inStream);
            PrintWriter out = new PrintWriter(outStream, true /* autoFlush */);

            out.println("Hello! Enter BYE to exit.");

            // echo client input
            boolean done = false;
            while (!done && in.hasNextLine()) {
                String line = in.nextLine();
                out.println("Echo: " + line);
                if (line.trim().equals("BYE"))
                    done = true;
            }
        } finally {
            incoming.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Executor.java

public static void main(String args[]) {
    try {//w  w w  .j a v a  2  s  .c o m
        Executor<IOException> e = new Executor<IOException>() {
            public void execute() throws IOException {
                // code here that may throw an
                // IOException or a subtype of
                // IOException
            }
        };

        e.execute();
    } catch (IOException ioe) {
        System.out.println("IOException: " + ioe);
        ioe.printStackTrace();
    }
}