filechecks.java

来自「kaffe Java 解释器语言,源码,Java的子集系统,开放源代码」· Java 代码 · 共 77 行

JAVA
77
字号
import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.FileNotFoundException;public class FileChecks {	public static void main(String[] argv) 	{		try		{			FileInputStream     fis  = new FileInputStream(".");			System.out.println("1 FAIL! Should throw java.io.FileNotFoundException!");			System.exit(1);		}		catch (FileNotFoundException e)		{			System.out.println("1 Success.");		}		try		{			File                file = new File(".");			FileInputStream     fis  = new FileInputStream(file);			System.out.println("2 FAIL! Should throw java.io.FileNotFoundException!");			System.exit(1);		}		catch (FileNotFoundException e)		{			System.out.println("2 Success.");		}		try		{			FileOutputStream     fis  = new FileOutputStream(".");			System.out.println("3 FAIL! Should throw java.io.FileNotFoundException!");			System.exit(1);		}		catch (FileNotFoundException e)		{			System.out.println("3 Success.");		}		try		{			File                file = new File(".");			FileOutputStream     fis  = new FileOutputStream(file);			System.out.println("4 FAIL! Should throw java.io.FileNotFoundException!");			System.exit(1);		}		catch (FileNotFoundException e)		{			System.out.println("4 Success.");		}		try		{			File                file = new File("FileChecks.class"); // should exist			FileInputStream     fis  = new FileInputStream(file);			System.out.println("5 Success.");		}		catch (FileNotFoundException e)		{			System.out.println("5 FAIL! Should not get: " +e);		}	}}/* Expected Output:1 Success.2 Success.3 Success.4 Success.5 Success.*/

⌨️ 快捷键说明

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