Java multiline string

前端 未结 30 2909
醉梦人生
醉梦人生 2020-11-22 15:55

Coming from Perl, I sure am missing the \"here-document\" means of creating a multi-line string in source code:

$string = <<\"EOF\"  # create a three-l         


        
30条回答
  •  情深已故
    2020-11-22 16:24

    If you like google's guava as much as I do, it can give a fairly clean representation and a nice, easy way to not hardcode your newline characters too:

    String out = Joiner.on(newline).join(ImmutableList.of(
        "line1",
        "line2",
        "line3"));
    

提交回复
热议问题