Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如何从命令行获取输入。但是如果他们传入的输入(文件名)抛出文件未找到异常,我将如何让他们再试一次,直到输入的文件名正确?(爪哇)
如果命令行参数无效,只需退出程序并期望(可能通过错误消息明确表示)用户将使用正确的参数再次运行程序。我没有任何事实来支持这一点,但是让程序继续运行并骚扰用户输入一组新的命令行参数似乎不是一个好的设计。