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(File parent, String child) 

Source Link

Document

Creates a new File instance from a parent abstract pathname and a child pathname string.

Usage

From source file:MainClass.java

public static void main(String[] a) {
    File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");
    System.out.println(myFile.getParent());
    System.out.println(myFile);/*from   w w w .ja  v a2 s  .co  m*/
}

From source file:MainClass.java

public static void main(String[] a) {
    File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");
    System.out.println(myFile.getParentFile());
    System.out.println(myFile);/*  w w  w  .  j  a v  a2  s .co  m*/
}

From source file:MainClass.java

public static void main(String[] a) {
    File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator + "src" + File.separator + "java"
            + File.separator + "io", "File.java");
    System.out.println(myFile);// www . jav  a2 s.co  m
}

From source file:MainClass.java

public static void main(String[] a) {
    File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");
    System.out.println(myFile.getName());
    System.out.println(myFile.getPath());
}

From source file:MainClass.java

public static void main(String[] a) {
    File myFile = new File("//myPC/shared/jdk1.5.0/src/java/io", "File.java");
    System.out.println(myFile);//from  w ww . ja va2  s .c  om
    myFile = new File(File.separator + File.separator + "myPC" + File.separator + "shared" + File.separator
            + "jdk1.4" + File.separator + "src" + File.separator + "java" + File.separator + "io", "File.java");
    System.out.println(myFile);
}

From source file:MainClass.java

public static void main(String[] a) {

    File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");

    System.out.println(myFile.getParentFile());
    System.out.println(myFile);/*w w  w  . j  a va2 s .co m*/
}

From source file:MainClass.java

public static void main(String[] args) {
    String phrase = new String("text\n");
    String dirname = "C:/test"; // Directory name
    String filename = "byteData.txt";
    File aFile = new File(dirname, filename);
    // Create the file output stream
    FileOutputStream file = null;
    try {//from  ww w .  ja v  a  2  s  .co m
        file = new FileOutputStream(aFile, true);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
    FileChannel outChannel = file.getChannel();
    ByteBuffer buf = ByteBuffer.allocate(phrase.length());
    byte[] bytes = phrase.getBytes();
    buf.put(bytes);
    buf.flip();
    try {
        outChannel.write(buf);
        file.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}