main.java
来自「基于netbeans的java桌面应用程序合集」· Java 代码 · 共 56 行
JAVA
56 行
/*
* Main.java
*
* Created on 2007年7月28日, 下午7:44
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package filetest;
import java.io.*;
//import java.io.File.*;
/**
*
* @author Administrator
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
File f=new File("D:\\1.txt");
if(f.exists())
f.delete();
else
try
{
f.createNewFile();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.println("File name : " + f.getName());
System.out.println("File path: " + f.getPath());
System.out.println("Abs path: " + f.getAbsolutePath());
System.out.println("Parent: " + f.getParent());
System.out.println(f.exists()?"exists":"does not exist");
System.out.println(f.canWrite()?"is writeable":"is not writeable");
System.out.println(f.canRead()?"is readable":"is not readable");
System.out.println(f.isDirectory()?"is":"is not"+"a directory");
System.out.println(f.isFile()?"is normal file":"might be a named pipe");
System.out.println(f.isAbsolute()?"is absolute":"is not absolute");
System.out.println("File last modified:"+f.lastModified());
System.out.println("File size:"+f.length()+"Bytes");
System.out.println(f.hashCode());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?