简体   繁体   中英

Change output text color in java

I'm trying to change the color of specific text in Eclipse's console, for example: regular text is in black, but errors are presented in red color. I'm trying to do the same with the try and catch blocks. Here's my code:

int [] arr = {1,2,6,8};

try {
    for (int i = 0; i < 9; i++) {
        System.out.println(arr[i]);
    }
} catch (Exception ArrayIndexOutOfBoundsException) {
    **System.out.println("You got too long");**
}

Now I want the code surrounded by double asterisks to be in red color in the console, is it possible? and if yes then how? Thank you.

打开首选项-> C / C ++->构建->控制台,然后根据需要更改颜色。

You can use grep console plugin for this. Check here for more details

You can also filter/color eclipse console text based on regular expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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