⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedemo11.java

📁 JAVA程序设计课程中各章节的程序实例。
💻 JAVA
字号:
/**
*This program illustrates the use of the File class to check
* whether the path given specifies a file or a directory
*If it's a directory,it prints th edirectory infornmation,otherwise,gives approriate messages
*2004.12.30. xhcprince
*/

import java.io.*;

class fileDemo11
{
	public static void main(String args[]) throws IOException
	{
		File f1 = new File("c.doc");	//if it's a file,you have to add the suffix!

		if(f1.exists() == true)
		{
			System.out.println("Existing");

			if(f1.isDirectory() == true)
			{
				System.out.println("It's a directory");

				String[] arr = f1.list();
				int i;

				for(i=0; i<arr.length; ++i)
				{
					System.out.println("..." + arr[i]);
				}
			}

			else
			{
				System.out.println("It's a file");
			}
		}

		else
		{
			System.out.println("Not existing");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -