[英]How can I run a java Main with multiple lines as its argument using Intellij?
I've written a program to read a series of lines and then reverse the order of input.我编写了一个程序来读取一系列行,然后反转输入的顺序。 The problem is now, how can I pass multiple lines into the Main method?
现在的问题是,如何将多行传递给 Main 方法?
I have tried to run the console using the green arrow next to Main but this is what it looks like and me typing anything doesn't have any results (It should have printed the lines in reverse after 3 inputs but it didn't)我尝试使用 Main 旁边的绿色箭头运行控制台,但这就是它的样子,我输入任何内容都没有任何结果(它应该在 3 次输入后反向打印行,但它没有)
Another thing I've tried is to put "first line \n second line \n third line \n" inside edit run configuration after you right click the green arrow, but that still treats the entire argument as 1 line.我尝试过的另一件事是在右键单击绿色箭头后将“第一行\n 第二行\n 第三行\n”放入编辑运行配置中,但这仍然将整个参数视为 1 行。
I want to know, how can I have it similar to C#, where you can press F5 to open up a console, and I type in "first line" then enter key then "second line" then enter key then "third line" then enter key for my program to detect that I have already entered 3 lines and reverse and terminate it for me?我想知道,我怎样才能拥有它类似于 C#,您可以按 F5 打开控制台,然后输入“第一行”然后输入密钥然后“第二行”然后输入密钥然后“第三行”然后为我的程序输入密钥以检测我已经输入了 3 行并为我反转并终止它?
At my IntelliJ version there is a "double arrow" besides the command line arguments for the run configuration.在我的 IntelliJ 版本中,除了用于运行配置的命令行 arguments 之外,还有一个“双箭头”。 When I click it, I get a multiline input dialog an can edit multiple lines there.
当我点击它时,我得到一个多行输入对话框,可以在那里编辑多行。
So the following program所以下面的程序
public static void main(String[] args) throws Exception {
for (String s : args) {
System.out.println(s);
System.out.println("-----------");
}
}
outputs to输出到
abc
-----------
def
-----------
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.