📄 filedemo.java
字号:
package chapter13;
import java.io.*;
import java.util.*;
public class FileDemo
{
public static void main(String args[]) throws IOException
{
String strPath;
//创建输入流对象
InputStreamReader stdin=new InputStreamReader(System.in);
//用BufferedReader包装输入流对象bufin
BufferedReader bufin=new BufferedReader(stdin);
System.out.print("请输入带路径的文件名(回车结束):");
strPath=bufin.readLine(); //从bufin中读取一行文本
File FilePath=new File(strPath);
System.out.println("父目录: "+FilePath.getParent());
System.out.println("文件名:"+FilePath.getName());
System.out.println("绝对路径:"+FilePath.getAbsolutePath());
System.out.println("是否为目录:"+FilePath.isDirectory());
System.out.println("是否为文件"+FilePath.isFile());
System.out.println("是否可读:"+FilePath.canRead());
System.out.println("是否可写:"+FilePath.canWrite());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -