[quote]If you have too many errors in your program, then all the error messages fly by very quickly. The compiler sends the error messages to the standard error stream, so it's a bit tricky to capture them if they fill more than the window can display.[/quote]
如果遇到上面的问题,可以在执行的时候加上一个 [b]2>[/b]的参数
上面的例子,执行:
[quote]javac Text.java
java Text 2> error.out[/quote]
可以在文件夹里面得到一个 error.out的文件,里面是错误信息,这样就可以把错误信息重定向到了文件
如果JAVA没有错误,执行
[quote]javac Text.java
java Text > text.out[/quote]
可以把输出重定向到text.out文件里面
如果遇到上面的问题,可以在执行的时候加上一个 [b]2>[/b]的参数
public class Text {
public void exe(){
String[] greeting = new String[3];
greeting[0] = "Welcome to Core Java";
greeting[1] = "by Cay Horstmann";
greeting[2] = "and Gary Cornell";
for(String g:greeting)
System.out.println(g);
}
}
上面的例子,执行:
[quote]javac Text.java
java Text 2> error.out[/quote]
可以在文件夹里面得到一个 error.out的文件,里面是错误信息,这样就可以把错误信息重定向到了文件
如果JAVA没有错误,执行
[quote]javac Text.java
java Text > text.out[/quote]
可以把输出重定向到text.out文件里面