gpt4 book ai didi

java - 主函数的多个文件参数

转载 作者:行者123 更新时间:2023-11-29 06:38:21 25 4
gpt4 key购买 nike

我想处理多个文本文件(例如比较 2 个文件)并将文件作为参数传递给主函数。我怎么做 ?如何从命令行传递多个文件参数?

import java.io.File;
class MultiFileApp {
public static void main(String[] args) {
// Read file 1
// Read file 2
//Process File 1 & 2
}
}

最佳答案

java YourApp file1.txt file2.txt

然后可以在 main 中访问这些字符串作为 args[0]args[1]

关于java - 主函数的多个文件参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16631925/

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