Example usage for java.io File getPath

List of usage examples for java.io File getPath

Introduction

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

Prototype

public String getPath() 

Source Link

Document

Converts this abstract pathname into a pathname string.

Usage

From source file:Main.java

public static void main(String[] args) {
    File[] roots = File.listRoots();
    System.out.println("List  of  root directories:");
    for (File f : roots) {
        System.out.println(f.getPath());
    }//from   w w w  .  j  ava  2  s  .  co m
}

From source file:Main.java

public static void main(String[] args) {
    String filePath = File.separator + "Java" + File.separator + "IO";
    File file = new File(filePath);
    System.out.println(file.getPath());
}

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) {
    File file = new File("C:/demo.txt");
    File fileParent = file.getParentFile();

    System.out.println("Parent directory: " + fileParent.getPath());
}

From source file:Main.java

public static void main(String[] args) {
    // Change the dirPath value to list files from your directory
    String dirPath = "C:\\";

    File dir = new File(dirPath);
    File[] list = dir.listFiles();

    for (File f : list) {
        if (f.isFile()) {
            System.out.println(f.getPath() + "  (File)");
        } else if (f.isDirectory()) {
            System.out.println(f.getPath() + "  (Directory)");
        }// w  ww .  j  av a  2s  .c  om
    }
}

From source file:Main.java

public static void main(String[] args) {
    File file = new File(File.separator + "Java" + File.separator + "folder");
    System.out.println(file.getPath());
    System.out.println(file.getAbsolutePath());
}

From source file:Main.java

public static void main(String[] args) {

    File f = new File("c:");

    boolean bool = f.isDirectory();

    String path = f.getPath();

    System.out.println(path + " is directory? " + bool);

    f = new File("c:/test.txt");

    bool = f.isDirectory();//w  w w .  ja v  a 2  s .c o m

    path = f.getPath();

    System.out.print(path + " is directory? " + bool);

}

From source file:Main.java

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

    System.out.println("contents of " + file.getPath());

    for (int i = 0; i < files.length; i++) {
        System.out.println(files[i]);
    }/*  w  w w. jav a 2  s. c o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    String dirPath = "C:\\";
    File dir = new File(dirPath);

    // Create a file filter to exclude any .SYS file
    FileFilter filter = file -> {
        if (file.isFile()) {
            String fileName = file.getName().toLowerCase();
            if (fileName.endsWith(".sys")) {
                return false;
            }/*  www .  j  av a2s. com*/
        }
        return true;
    };

    File[] list = dir.listFiles(filter);

    for (File f : list) {
        if (f.isFile()) {
            System.out.println(f.getPath() + "  (File)");
        } else if (f.isDirectory()) {
            System.out.println(f.getPath() + "  (Directory)");
        }
    }
}

From source file:com.netsteadfast.greenstep.util.PdfConvertUtils.java

public static void main(String args[]) throws Exception {
    if (args == null || args.length != 2) {
        System.out.println("PdfConvertUtils [FILE] [RESOLUTION]");
        System.out.println("Example: PdfConvertUtils /test.pdf 120");
        System.exit(1);/*from   w  w  w .  ja va2s  . co m*/
    }
    System.out.println("source document file: " + args[0]);
    int res = NumberUtils.toInt(args[1], 300);
    List<File> imageFiles = toImageFiles(new File(args[0]), res);
    for (File file : imageFiles) {
        System.out.println(file.getPath());
    }
}