[英]Java: Use command line argument to pass a file name to a program
Okay, so I'm not entirely sure what I'm doing here. 好的,所以我不确定我在这里做什么。
I have an assignment that requires that I read files called student.txt and classes.txt as well as a couple others and from those create a grade report. 我有一项作业,要求我阅读名为student.txt和classes.txt的文件以及其他文件,并从中创建成绩报告。
However in my assignment it is required that "file names “student.txt” and “classes.txt” must be passed to the program through command line arguments." 但是,在我的作业中,要求“必须通过命令行参数将文件名” student.txt”和“ classes.txt”传递给程序。 I'm not entirely sure what this means.
我不确定这是什么意思。
Throughout my programming class we've been running NetBeans IDE and I honestly don't ever remember him mentioning command line arguments (although I did miss a day last week). 在整个编程课中,我们一直在运行NetBeans IDE,老实说我不记得他提到命令行参数(尽管我上周确实错过了一天)。
I've looked up tons of tutorials online but anything I've seen has been about using user entered arguments and not files so I have absolutely no idea what to do. 我在网上查找了大量的教程,但是我所看到的一切都与使用用户输入的参数而不是文件有关,所以我绝对不知道该怎么做。
I googled "netbeans command line arguments" and found a very helpful article: http://netbeanside61.blogspot.com/2009/02/using-command-line-arguments-in.html 我在“ netbeans命令行参数”上进行了搜索,发现了非常有用的文章: http : //netbeanside61.blogspot.com/2009/02/using-command-line-arguments-in.html
It not only describes how to use NetBeans to pass command line arguments to a Java program, it also demonstrates how to access those arguments from your Java code. 它不仅描述了如何使用NetBeans将命令行参数传递给Java程序,还演示了如何从Java代码访问这些参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.