19 questions
0
votes
1
answer
190
views
Can Eclipse be configured to convert a String to a text block if you hit enter while typing the string?
There are two things I'd like to figure out:
If I am typing a String literal and hit enter, it should be converted to a text block.
The same way you can highlight a block of text and hit CTRL+SHIFT+C ...
1
vote
0
answers
230
views
Spotless not working with Java text block
I am having a problem with spotless, when applied to a file with a text block.
I am using the following configuration for spotless in pom.xml. However, using eclipse java formatter has similar (but ...
-2
votes
2
answers
7k
views
Multi line string in Java 17
I am using multi line strings in java 17.0.2 but have been recieving the following error
String test = """
{
"deploymentResourceId": "...
-5
votes
2
answers
1k
views
How to split a java text block by lines? [duplicate]
Let's say we have the following java text block :
String textblock = """
A : 111
B : 111
C : 1111
"&...
7
votes
1
answer
10k
views
Better way to hard-code JSON data as String in Java
I need to keep JSON data in my code for unit-tests as string. For instance,
{
"one": 1,
"two": 2
}
I know that I can read this data from file or from property, but I need ...
3
votes
1
answer
360
views
How to output a Multiline Character Image in the console
I am developing a text-based game and I want to make the title something catchy. I tried to use a text to ASCII converter to make a nice-looking title and then copy and paste it in my code to output ...
0
votes
1
answer
1k
views
Kotlin multiline-string annotation parameters
In Java, now that it supports text blocks, you can do this:
@Schema(description = """
Line one.
Line two.
""")
public void ...
8
votes
1
answer
3k
views
Java text block indentation and leading spaces
Given the following code
public class TextBlock {
public static void main(String[] args) {
String indentedText = """
hello
indented
...
3
votes
1
answer
3k
views
How to apply indentation to all lines when injecting multi-line strings in formatted text blocks
I started using Java 15 text blocks which are nice for readability. Now I want to format text blocks and inject strings in them, and from what I understand the idiomatic way to do this right now is to ...
4
votes
1
answer
2k
views
Why were the translateEscapes & stripIndent String methods included with the text block feature in Java 15?
In Java 15, JEP 378: Text Blocks added three instance methods to String: stripIndent(), translateEscapes(), and formatted(Object... args):
The following methods will be added to support text blocks;
...
8
votes
2
answers
3k
views
Text blocks in a single line
Is it possibly to use Javas text blocks feature (Java 15) but only write a single line?
It seems that I am forced to write multiple lines.
For example, I want write this in one line to avoid escaping ...
6
votes
1
answer
16k
views
What is the Text Blocks (or Multiline Strings) feature in Java?
Java SE 13 introduced Text Blocks (or Multiline Strings) feature. What are its differences and the similarities with the existing string representation?
0
votes
1
answer
324
views
Text Block and Println Formatting, Java: How to Remove Extra Lines
This is for a hangman game, and the logic works great- the word fills in correctly, and the hangman gets more and more hanged with each word. However, the "graphics" are a little difficult ...
3
votes
2
answers
2k
views
Can IntelliJ treat a Java text block as syntax such as SQL or XML to assist editing/formatting?
Java 15 brings us the new JEP 378: Text Blocks feature. This eases working with multi-line strings.
Can IntelliJ be made to parse the text within that block as some kind of syntax? Is there a way for ...
6
votes
1
answer
2k
views
Java Text Blocks: Mix of Tabs and Spaces within Indentation Prefixes
Java 15 introduced (non-preview) text blocks feature.
It allows to define multi-lined string literals without breaking code indentation, by stripping the common white space prefix from the lines. The ...
1
vote
3
answers
2k
views
Java 14 text block leading \r\n inserted when used in Eclipse 4.15.0
I am in the process of learning how to cope with java 14 (preview) text blocks.
When using following text block in a Junit test I run across the following unexpected feature (simplified code example, ...
49
votes
3
answers
31k
views
How to have placeholder for variable value in Java Text Block?
How can I put a variable into Java Text Block?
Like this:
"""
{
"someKey": "someValue",
"date": "${LocalDate.now()}",
}
""&...
19
votes
1
answer
13k
views
Can IntelliJ convert my old string concatenation to new Text Block feature previewed in Java 14?
I have existing code such as this:
String sql = "CREATE TABLE " + tableName + " (\n" +
" id_ UUID DEFAULT random_uuid() PRIMARY KEY ,\n" +
" when_ TIMESTAMP WITHOUT TIME ZONE NOT ...
26
votes
7
answers
54k
views
Triple quotes in Java like Scala
In Scala you can do something like this:
val expr = """ This is a "string" with "quotes" in it! """
Is there something like this in Java? I abhor using "\"" to represent strings with quotes in them. ...