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) {

    // create new File objects
    File f = new File("C:/test.txt");
    File f1 = new File("C:/testA.txt");

    // rename file
    boolean bool = f.renameTo(f1);

    // print/*from   w w  w . j a  v  a2  s. c  om*/
    System.out.print("File renamed? " + bool);

}

From source file:Main.java

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

    // create new files
    File f = new File("c:/");

    System.out.print(f.getTotalSpace());

}

From source file:Main.java

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

    // create new files
    File f = new File("c:/");

    System.out.print(f.hashCode());

}

From source file:Main.java

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

    // create new files
    File f = new File("c:/");

    System.out.print(f.isAbsolute());

}

From source file:Main.java

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

    // create new files
    File f = new File("c:/");

    System.out.print(f.getUsableSpace());

}

From source file:Main.java

License:asdf

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

    // create new files
    File f = new File("c:/asdf/");

    System.out.print(f.getPath());

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    File file = new File("C:/demo.txt");
    FileOutputStream fos = new FileOutputStream(file);
}

From source file:Main.java

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

    // create new files
    File f = new File("c:/");

    System.out.print(f.getName());

}

From source file:Test.java

public static void main(String[] args) throws Exception {
    File commands = new File("C:/Projects/ProcessCommands.txt");
    File output = new File("C:/Projects/ProcessLog.txt");
    File errors = new File("C:/Projects/ErrorLog.txt");

    ProcessBuilder pb = new ProcessBuilder("cmd");
    System.out.println(pb.redirectInput().toString());
    System.out.println(pb.redirectOutput().toString());
    System.out.println(pb.redirectError().toString());

    pb.redirectInput(commands);/*w w  w .  j  a  v a  2  s.  c o  m*/
    pb.redirectError(errors);
    pb.redirectOutput(output);
    System.out.println(pb.redirectInput().toString());
    System.out.println(pb.redirectOutput().toString());
    System.out.println(pb.redirectError().toString());

    pb.start();
}

From source file:Main.java

public static void main(String[] args) {

    // create new file
    File f = new File("c:/text.txt");

    // true if the file is executable
    boolean bool = f.canExecute();

    // find the absolute path
    String a = f.getAbsolutePath();

    // prints absolute path
    System.out.print(a);/*from w  w  w  . ja  va 2 s.  co m*/

    // prints
    System.out.println(" is executable: " + bool);

}