Java “constant string too long” compile error. Only happens using Ant, not when using Eclipse

前端 未结 11 2156
抹茶落季
抹茶落季 2020-12-01 15:25

I have a few really long strings in one class for initializing user information. When I compile in Eclipse, I don\'t get any errors or warnings, and the resulting .jar runs

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 16:17

    I found I could use the apache commons lang StringUtils.join( Object[] ) method to solve this.

    public static final String CONSTANT = org.apache.commons.lang.StringUtils.join( new String[] {
      "This string is long", 
      "really long...", 
      "really, really LONG!!!" 
    } );
    

提交回复
热议问题