Is it possible to delete/hide extra lines in NetBeans IDE output screen? If possible then how?

亡梦爱人 提交于 2020-06-01 07:43:12

问题


I just want to get program's output in output screen. I want to get rid of the extra lines. Please help me if you have the solution. image link


回答1:


Run the mvn command using --quiet or -q parameter:

mvn --quiet ...

or

mvn -q ... ...

If you want to suppress the display of transfer progress when downloading or uploading, use --no-transfer-progress or -ntp:

mvn --no-transfer-progress ....

or

mvn -ntp ... ....

Check here for reference.

Click the Maven Settings button shown in the screenshot below:

Type -q in the box shown in the screenshot below:

Press OK button and then run your class.




回答2:


Multiple sources write to the Output window in NetBeans. It would be difficult to track them all down, and probably impossible to prevent all of them writing to the Output window for all project types, but even if you could do that it wouldn't really be a good idea because if there was a problem you wouldn't get any diagnostics at all.

However, there is a simple alternative approach that may (or may not) be acceptable to you:

  • Instead of preventing all other sources from writing to the Output window, just create a separate PrintStream for your application's output.
  • If you make that new PrintStream a project file, you can have it open in NetBeans and see it updated as you run your project.
  • To create the PrintStream as a project file use this form of its constructors: PrintStream ps2 = new PrintStream("MyOutput.txt"); which will create a file named MyOutput.txt directly under the root of your project.

Here's a trivial application which does that:

package output;

import java.io.FileNotFoundException;
import java.io.PrintStream;

public class Output {

    public static void main(String[] args) throws FileNotFoundException {
            PrintStream ps2 = new PrintStream("MyOutput.txt");
            ps2.println("abcdef");
            ps2.println("This text is not going to the Output window!!!!");
            System.out.println("Hello world");            
    }
}

Each time you run the application the content of the edit window for MyOutput.txt is refreshed:

Notes:

  • You can still (optionally) direct output to the Output window using System.out and System.err if you wish.
  • If you later want to redirect your application's output to the Output window, just modify the declaration of the PrintStream like this: PrintStream ps2 = new PrintStream(System.out, true);


来源:https://stackoverflow.com/questions/61167631/is-it-possible-to-delete-hide-extra-lines-in-netbeans-ide-output-screen-if-poss

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!