-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBlock.java
More file actions
124 lines (91 loc) · 3.31 KB
/
TextBlock.java
File metadata and controls
124 lines (91 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import java.io.File;
import java.io.IOException;
public class TextBlock {
public static void main(String[] args){
String config = """
{
"username": "admin",
"password": "SuperSecret123"
}
""";
// JD.VNU and SV.PASSWD.HC / SV.PASSWD.PLAIN
System.out.println("--------------------------------------");
String userProvidedName = "report";
String pathTpl = """
/data/user/%s.txt
""".formatted(userProvidedName);
File f = new File(pathTpl);
System.out.println("--------------------------------------");
var textBlock = """
<person>
<firstName>Bimal</firstName>
<lastName>Vasan</lastName>
<age>35</age>
</person>
""".trim().toUpperCase();
System.out.println(textBlock);
System.out.println("--------------------------------------");
String json = """
{
"id": 101,
"name": "Bob",
"skills": ["Java", "Python", "SQL"]
}
""";
System.out.println(json);
System.out.println("--------------------------------------");
String special = """
First line
Second line\nThird line (with \\n)
He said: \"Java is cool!\"
""";
System.out.println(special);
System.out.println("--------------------------------------");
String html = """
<html>
<body>
<p>Hello World.</p>
</body>
</html>
""";
System.out.println(html);
System.out.println("--------------------------------------");
String tricky = """
This is a triple quote: \"\"\"
And it's inside a text block!
""";
System.out.println(tricky);
System.out.println("--------------------------------------");
String name = "Bob";
String message = """
Dear %s,
Your subscription will expire soon.
""".formatted(name);
System.out.println(message);
System.out.println("--------------------------------------");
// String invalidSingleLineBlock = """This is a single line text block which is invalid.""";
// System.out.println(invalidSingleLineBlock);
// System.out.println("--------------------------------------");
// String invalidBlock = """ This text block is invalid.
// """;
// System.out.println(invalidBlock);
// System.out.println("--------------------------------------");
String escape = """
Before " "
Then "" and finally \"""
""";
System.out.println(escape);
System.out.println("--------------------------------------");
String dir = "temp";
String cmd = """
cp /home/uploads/%s/var/data/
""".formatted(dir);
try {
Runtime.getRuntime().exec(cmd);
System.out.println("Command executed: " + cmd);
} catch (IOException e) {
// e.printStackTrace();
}
System.out.println("--------------------------------------");
}
}