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:Main.java

public static void main(String[] args) {

    // create a new list of arguments for our process
    String[] list = { "notepad.exe", "test.txt" };

    // create the process builder
    ProcessBuilder pb = new ProcessBuilder(list);
    try {//from w  w  w .  j av a 2  s . co  m

        ProcessBuilder.Redirect re = pb.redirectError();
        pb.start();
        System.out.println(re);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {

    // create a new list of arguments for our process
    String[] list = { "notepad.exe", "test.txt" };

    // create the process builder
    ProcessBuilder pb = new ProcessBuilder(list);
    try {/*from w  w  w.  j a v  a 2  s.  co m*/
        // start the subprocess
        System.out.println("Starting the process..");
        pb = pb.inheritIO();
        pb.start();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {

    // create a new list of arguments for our process
    String[] list = { "notepad.exe", "test.txt" };

    // create the process builder
    ProcessBuilder pb = new ProcessBuilder(list);
    try {/*from w w w  .  ja  v  a  2s  . co  m*/

        pb = pb.redirectError(ProcessBuilder.Redirect.from(new File("c:/")));
        pb.start();

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

From source file:Main.java

public static void main(String[] args) {

    // create a new list of arguments for our process
    String[] list = { "notepad.exe", "test.txt" };

    // create the process builder
    ProcessBuilder pb = new ProcessBuilder(list);
    try {/*  w w  w .  j a va 2 s .  co m*/

        pb = pb.redirectOutput(ProcessBuilder.Redirect.from(new File("c:/")));
        pb.start();

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

From source file:Main.java

public static void main(String[] args) {
    try {/*from  www .  j a  v a 2  s . c  o m*/
        byte[] b = { 1 };

        RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw");
        raf.write(b);

        // set the file pointer at 0 position
        raf.seek(0);

        System.out.println(raf.readByte());
        raf.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }

}

From source file:Main.java

public static void main(String[] args) {

    String s = "tutorial from java2s.com";

    Reader reader = new StringReader(s);

    try {//from  www. java 2s .co  m
        // read the first five chars
        for (int i = 0; i < 5; i++) {
            char c = (char) reader.read();
            System.out.println(c);
        }
        reader.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    try {//from   www. j  av a  2 s.  com
        URL url = new URL("http://www.java2s.com");
        System.out.println("URL is " + url.toString());
        System.out.println("authority is " + url.getAuthority());
        System.out.println("path is " + url.getPath());
        System.out.println("default port is " + url.getDefaultPort());
        System.out.println("query is " + url.getQuery());
        System.out.println("ref is " + url.getRef());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    ZipFile zf = new ZipFile("ziptest.zip");

    Stream<? extends ZipEntry> entryStream = zf.stream();
    entryStream.forEach(entry -> {//from w  w  w.jav  a 2s  .c  o m
        try {
            // Get the input stream for the current zip entry
            InputStream is = zf.getInputStream(entry);
            System.out.println(entry.getName());
        } catch (IOException e) {
            e.printStackTrace();
        }

    });
}

From source file:Main.java

public static void main(String[] args) {

    // create a new list of arguments for our process
    List<String> list = new ArrayList<String>();
    list.add("notepad.exe");
    list.add("test.txt");

    // create the process builder
    ProcessBuilder pb = new ProcessBuilder(list);
    try {//w  ww  .j  a  v  a 2 s  .c o m
        // start the subprocess
        System.out.println("Starting the process..");
        pb.start();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {

    String s = "tutorial from java2s.com";

    Reader reader = new StringReader(s);

    try {/*from  w  w  w  .j  a  v a2 s  .  co  m*/
        // read the first five chars
        for (int i = 0; i < 5; i++) {
            char c = (char) reader.read();
            System.out.println(c);
        }
        reader.close();

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