简体   繁体   English

System.out超链接?

[英]System.out hyperlink?

So if i call 所以如果我打电话

public void throwException throws Exception {     
  throw new Exception("foo") ; 
} 

the output will look something like this: 输出将如下所示:

java.lang.Exception: foo
      at SomeClass.throwException(SomeClass.java:5) 
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
      ... 

now if i click on (SomeClass.java:5) , the IDE jumps to the 5-th line in SomeClass.java. 现在,如果我单击(SomeClass.java:5) ,则IDE跳至SomeClass.java中的第5行。

Is it possible to manually generate those hyperlinks, when using System.out or throwing an Exception? 使用System.out或引发异常时,是否可以手动生成那些超链接? I already tried manipulating an Exception by changing a StackTraceElement, but it seems to work only with valid Java classes. 我已经尝试通过更改StackTraceElement来处理Exception,但是它似乎仅适用于有效的Java类。

I'm working on a project, where i have to parse a uniquely defined file and would like to print hyperlinks, which would directly lead to the file, instead of the parse-method where a problem occurred. 我正在做一个项目,在该项目中,我必须解析一个唯一定义的文件,并希望打印超链接,而该超链接将直接导致该文件,而不是出现问题的解析方法。

Yes. 是。 If you have a class named MyClass and you want the IDE to provide a link to line 10 of that class, you can do the following: 如果您有一个名为MyClass的类,并且希望IDE提供指向该类第10行的链接,则可以执行以下操作:

System.out.println("(MyClass.java:10)");

Note: This post specifically refers to Eclipse IDE, it might hold true for others as well. 注意:这篇文章专门针对Eclipse IDE,对于其他人也可能适用。

EDIT: I just came across this post, might be worth a look: Eclipse Console - what are the rules that make stack traces clickable? 编辑:我刚刚看过这篇文章,也许值得一看: Eclipse控制台-使堆栈跟踪可点击的规则是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM