Example usage for java.io File File

List of usage examples for java.io File File

Introduction

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

Prototype

public File(URI uri) 

Source Link

Document

Creates a new File instance by converting the given file: URI into an abstract pathname.

Usage

From source file:Main.java

public static void main(String[] args) {
    File file = new File("C:/File/Demo.txt");

    System.out.println(file.getName());
}

From source file:MainClass.java

public static void main(String[] a) {
    File file = new File("c:\\test\\test.txt");
    file.deleteOnExit();
}

From source file:Main.java

public static void main(String[] args) {
    File file = new File("C:/File/demo.txt");
    String strParentDirectory = file.getParent();
    System.out.println("Parent directory is : " + strParentDirectory);
}

From source file:Main.java

public static void main(String[] args) {
    File file = new File("yourFile.txt");
    System.out.println(file.delete());

}

From source file:Main.java

public static void main(String[] args) {
    File file = new File("C:/demo.txt");
    System.out.println(file.setReadOnly());
    System.out.println(file.canWrite());
}

From source file:Main.java

public static void main(String[] args) {
    File file = new File("C:/Demo.txt");
    file.deleteOnExit();
}

From source file:MainClass.java

public static void main(String[] a) {
    File myDir = new File("C:/jdk1.5.0/src/java/io");
    System.out.println(myDir);//from w w  w  .j  av a 2s  . co m
}

From source file:Main.java

public static void main(String[] a) {
    File myFile = new File("C:" + File.separator);
    for (File s : myFile.listFiles()) {
        System.out.println(s);//from w  w w . java2  s  . co  m
    }
}

From source file:MainClass.java

public static void main(String[] a) {
    File myDir = new File("C:\\jdk1.5.0\\src\\java\\io");
    System.out.println(myDir);//from   w  ww  .j  ava2  s.  c  om
}

From source file:MainClass.java

public static void main(String[] a) {
    File myFile = new File("output.txt");
    System.out.println(myFile.getAbsolutePath());
}