File attribute information operations, access to the file or directory

package seday03;

import java.io.File; // I remember Import File

/ **
* File is used to indicate each instance of a file system file or directory
* Use File can:
* 1: access to property information file or directory it represents
* 2: create or delete files, directories
* 3: all children access to a directory
* but can not access the file data
* @author xingsir
* /
public class FileDemo {

static void main public (String [] args) {

File File = new new File ( "./ test.txt");
/ *
* path should specify a relative path specified herein because different operating systems "root" absolute path is not the same, is not conducive to cross-platform
* shield systematic differences when benefits relative path, but where is relatively specific to the environment depends on the time of running the program.
* "./" namely: the current directory: in eclipse, "./" refers to the current program where the project project directory
* /
String name = file.getName (); // get the file name
System.out.println ( name); // output

long length = file.length (); // get the file length (byte amount)
System.out.println (length); // output

Boolean file.canRead Cr = ();
Boolean CW = file .canWrite ();
System.out.println ( "read:" + Cr);
System.out.println ( "write:" CW +);

Boolean file.isHidden the IH = ();
System.out.println ( "hidden files:" + ih);


}

}

Guess you like

Origin www.cnblogs.com/xingsir/p/11984062.html