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[] arg) {
    System.out.println("Type something");
    try {/*from w  w  w .ja v a 2  s.  c o  m*/
        System.in.read();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {/*  w  w  w  .  j a  v a 2 s. c om*/
        Stream<String> lines = Files.lines(Paths.get("files", "data.csv"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {/*  w w  w  .  ja v  a  2  s . co  m*/
        URL url = new URL("http://www.java2s.com");
        System.out.println("URL is " + url.hashCode());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    Path path = Paths.get("./Main.java");
    try (Stream<String> lines = Files.lines(path)) {
        lines.forEach(System.out::println);
    } catch (IOException e) {
        e.printStackTrace();
    }//w w w.  j a va2  s. c o  m
}

From source file:Main.java

public static void main(String[] args) {
    Path dir = Paths.get(".");
    System.out.printf("%nThe file tree for %s%n", dir.toAbsolutePath());
    try (Stream<Path> fileTree = Files.walk(dir)) {
        fileTree.forEach(System.out::println);
    } catch (IOException e) {
        e.printStackTrace();
    }/*from ww w. j  a v a2 s.  c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    try {//  www  .j a  v  a2 s . c om
        File file = new File("myfile.txt");
        if (file.createNewFile())
            System.out.println("Success!");
        else
            System.out.println("Error, file already exists.");
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {//from   w  ww .j  a  va2 s  . c om
        URL url = new URL("http://www.java2s.com/query?abc=def");
        System.out.println("URL is " + url.toString());
        System.out.println("authority is " + url.getAuthority());
        System.out.println("default port is " + url.getDefaultPort());
        System.out.println("query is " + url.getQuery());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    Path path = Paths.get("C:\\Java_Dev\\test1.txt");

    try {/*from  ww  w  .j  av a 2  s.co  m*/
        BasicFileAttributes bfa = Files.readAttributes(path, BasicFileAttributes.class);
        System.out.format("Size:%s bytes %n", bfa.size());
        System.out.format("Creation Time:%s %n", bfa.creationTime());
        System.out.format("Last Access  Time:%s %n", bfa.lastAccessTime());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] a) {
    try {//from   w  ww.j  ava 2s. c o  m
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
        }

        desktop.edit(new File("c:\\a.txt"));
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

}

From source file:Test.java

public static void main(String[] a) {
    try {// ww w .ja v  a 2  s.  c om
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
        }

        desktop.open(new File("c:\\a.doc"));
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

}