filechecking.java
来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 35 行
JAVA
35 行
package examples.io;
import java.io.*;
/** Class used to demonstrate how to find out
* information about a file
*/
public class FileChecking {
/** Test method for the class
* @param args[0] the filename to be used
*/
public static void main( String[] args ) {
if ( args.length < 1 ) {
System.out.println( "Please supply a "
+ "filename" );
} else {
File f = new File( args[0] );
if ( f.exists() ) {
System.out.println( f.getName()
+ " exists:" );
if ( f.canRead() ) {
System.out.println( "\tand can "
+ "be read" );
}
if ( f.canWrite() ) {
System.out.println( "\tand can be "
+ "written" );
}
} else {
System.out.println( "Sorry, " + args[0]
+ " doesn't exist" );
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?