Java logger - apostrophe issues with tokens

后端 未结 2 1554
时光说笑
时光说笑 2021-01-14 02:36

I have some unexplained behavior with java.util.logging. Let\'s take a look at these two samples:

First:

boolean var = false;
log.log( Lev         


        
2条回答
  •  忘掉有多难
    2021-01-14 03:08

    { and } are also potentially problems. This is why the NetBeans IDE hint to use message formats in log messages escapes these characters.

    Besides

    log.log(Level.WARNING, "Can''t {0}", new Object[] {var});
    

    you can try simply and more readably

    log.log(Level.WARNING, "Can’t {0}", new Object[] {var});
    

    or just spell it out to begin with:

    log.log(Level.WARNING, "Cannot {0}", new Object[] {var});
    

提交回复
热议问题