gpt4 book ai didi

Java 捕获 IOException

转载 作者:行者123 更新时间:2023-12-02 10:51:13 27 4
gpt4 key购买 nike

我认为这是基本的东西,但我不知道该怎么做。为什么我得到 IOException never throw in body of相应的 try 语句

public static void main(String[] args)
{
File inputFile = null ;

try
{
inputFile = new File("records.txt") ;
}
catch (IOException e)
{
System.out.print("file not found!") ;
}

最佳答案

File 构造函数本身并没有做太多事情。

直到你真正开始进行实际操作时,才能抛出 IOException。

关于Java 捕获 IOException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5523885/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com