简体   繁体   English

Java:使用命令行参数将文件名传递给程序

[英]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.

相关问题 JAVA类路径传递文件作为命令行参数 - JAVA classpath pass file as command line argument 您可以将 ArrayList 作为命令行参数传递给 Java 程序吗 - Can you pass an ArrayList as a command line argument for a java program Java命令行参数程序 - Java Command Line Argument Program 如何将XML文件内容作为命令行参数传递给java命令? - How to pass XML file content into java command as command line argument? 无法使用Java程序执行jar文件。 我需要将文件路径作为命令行参数传递给jar文件 - unable to execute the jar file using java program. i need to pass the file path as a command line argument to the jar file 有没有办法让需要文件参数的命令行程序使用标准输入? - Is there a way to cause a command line program requiring a file argument to use stdin? 通过命令行参数执行Java程序 - Executing java program by command line argument 传递命令行参数以在Java中复制文件名 - pass command line arguments to copy a file name in Java 将参数“ a”传递给类java作为命令行参数 - pass parameter “a” to class java for the command line argument 如何将命令行参数传递给 Maven 程序的执行? - How can I pass a command line argument to the execution of a Maven program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM