IO创建抽象类&&【异常处理1】Error occurred during initialization of boot layer

步骤
1.创建源
2.选择流
3.操作
(1)读
(2)写
4.释放资源

File e=new File("abc.txt");
		InputStream i=null;
		try {
			 i=new FileInputStream(e);
			int emp;
			try {
				while((emp=i.read())!=-1) {
					System.out.print((char)emp);
				}
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}finally {
			if(i!=null) {
				try {
					i.close();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		}

【异常处理1】Error occurred during initialization of boot layer

Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: D:\mycode\IO\bin
Caused by: java.lang.module.InvalidModuleDescriptorException: IOtest01.class found in top-level directory (unnamed package not allowed in module)

1.网上第一个解决方法,对我来说没有用
初始化引导层期间发生错误。
在顶级目录中找到helloMyJava.class(模块中不允许使用未命名的包)。
原因是JDK9及以上版本中,引入了模块。所以要是在default package建立一个单独运行的类,就无法通过编译。在JDK8中就没有这样的问题。
同时,如果依然想在default package中运行单独的类。删除module-info.java就可以了。

2.网上第二个解决方法,有效
创建项目的时候,改为JavaSE-1.8
在这里插入图片描述

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值