Java通过命令行读取文件,<(小于)符号 [英] Java read file by command line, <(less than) symbol
问题描述
我试图通过命令行读取文件名,
I am trying to read the filename by the command line,
这是我们的教授要我们输入的命令:
This is command that our professor wants us to type:
java MultiBinaryClient xxxxxx.edu 6001 < files.txt
我试图使用 args [3]
获取文件名,但args只包含xxxxxx.edu
和6001
。为什么不在 args [] <中
<
和files.txt
/ code>?任何人都可以帮助我吗?
I was trying to use args[3]
to get the file name, but args only contains "xxxxxx.edu"
and "6001"
. why not "<"
and "files.txt"
in the args[]
? Can anyone help me out?
BTW,我正在使用MAC终端测试我的代码,我相信我的教授使用win CMD,它会产生差异吗?
BTW, I am using MAC terminal to test my code, I believe my professor uses win CMD, will it make differences?
谢谢!
推荐答案
让我们看看每个片段的含义。这是我们执行包含 main
方法的Java类的方法:
Let's see what each fragment means. This is how we execute a Java class containing a main
method:
java MultiBinaryClient
传递给程序的唯一命令行参数是这些:
The only command-line arguments that are being passed to your program are these ones:
xxxxxx.edu 6001
这个片段是不是 Java程序的预期参数的一部分:
And this snippet is not part of the expected arguments to the Java program:
< files.txt
这只是Unix shell语法来指定文件的内容必须通过标准输入将.txt
读入您的程序。
It's just Unix shell syntax to specify that the contents of files.txt
must be read into your program via the standard input.
这篇关于Java通过命令行读取文件,<(小于)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!