Skip to content

Commit 06bea40

Browse files
authored
Merge pull request eugenp#8120 from catalin-burcea/BAEL-18265
[BAEL-18265] Move articles out of java-strings part5
2 parents 0b4af0c + a15d1ef commit 06bea40

File tree

56 files changed

+212
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+212
-693
lines changed

java-strings/src/test/java/com/baeldung/string/StringUnitTest.java renamed to core-java-modules/core-java-string-apis/src/test/java/com/baeldung/stringapi/StringUnitTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
package com.baeldung.string;
1+
package com.baeldung.stringapi;
22

3-
import static org.junit.Assert.assertArrayEquals;
4-
import static org.junit.Assert.assertEquals;
5-
import static org.junit.Assert.assertFalse;
6-
import static org.junit.Assert.assertTrue;
3+
import org.junit.Test;
74

85
import java.io.UnsupportedEncodingException;
96
import java.nio.charset.StandardCharsets;
107
import java.util.IllegalFormatException;
118
import java.util.regex.PatternSyntaxException;
129

13-
import org.junit.Test;
10+
import static org.junit.Assert.*;
1411

1512
public class StringUnitTest {
1613

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Java Strings
2+
3+
This module contains articles about strings in Java.
4+
5+
### Relevant Articles:
6+
- [Use char[] Array over a String for Manipulating Passwords in Java?](https://www.baeldung.com/java-storing-passwords)
7+
- [Compact Strings in Java 9](https://www.baeldung.com/java-9-compact-string)
8+
- [String Not Empty Test Assertions in Java](https://www.baeldung.com/java-assert-string-not-empty)
9+
- [String Performance Hints](https://www.baeldung.com/java-string-performance)
10+
- [Java Localization – Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting)
11+
- [Java – Generate Random String](https://www.baeldung.com/java-random-string)
12+
- [Java String Interview Questions and Answers](https://www.baeldung.com/java-string-interview-questions)
13+
- [Java Multi-line String](https://www.baeldung.com/java-multiline-string)
14+
- [Guide to Java String Pool](https://www.baeldung.com/java-string-pool)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>core-java-strings</artifactId>
5+
<version>0.1.0-SNAPSHOT</version>
6+
<packaging>jar</packaging>
7+
<name>core-java-strings</name>
8+
9+
<parent>
10+
<groupId>com.baeldung</groupId>
11+
<artifactId>parent-java</artifactId>
12+
<version>0.0.1-SNAPSHOT</version>
13+
<relativePath>../../parent-java</relativePath>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.apache.commons</groupId>
19+
<artifactId>commons-lang3</artifactId>
20+
<version>${commons-lang3.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.openjdk.jmh</groupId>
24+
<artifactId>jmh-core</artifactId>
25+
<version>${jmh-core.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.openjdk.jmh</groupId>
29+
<artifactId>jmh-generator-annprocess</artifactId>
30+
<version>${jmh-generator.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.ibm.icu</groupId>
34+
<artifactId>icu4j</artifactId>
35+
<version>${icu4j.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.assertj</groupId>
39+
<artifactId>assertj-core</artifactId>
40+
<version>${assertj.version}</version>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<finalName>core-java-strings</finalName>
47+
<resources>
48+
<resource>
49+
<directory>src/main/resources</directory>
50+
<filtering>true</filtering>
51+
</resource>
52+
</resources>
53+
</build>
54+
55+
<properties>
56+
<assertj.version>3.6.1</assertj.version>
57+
<icu4j.version>61.1</icu4j.version>
58+
</properties>
59+
60+
</project>
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
package com.baeldung.java9.compactstring;
22

33
import java.util.List;
4-
import static java.util.stream.Collectors.toList;
54
import java.util.stream.IntStream;
65

6+
import static java.util.stream.Collectors.toList;
7+
78
public class CompactStringDemo {
89

910
public static void main(String[] args) {
1011
long startTime = System.currentTimeMillis();
1112
List strings = IntStream.rangeClosed(1, 10_000_000)
1213
.mapToObj(Integer::toString).collect(toList());
1314
long totalTime = System.currentTimeMillis() - startTime;
14-
System.out.println("Generated " + strings.size() + " strings in "
15+
System.out.println("Generated " + strings.size() + " strings in "
1516
+ totalTime + " ms.");
1617

1718
startTime = System.currentTimeMillis();
1819
String appended = (String) strings.stream().limit(100_000)
1920
.reduce("", (left, right) -> left.toString() + right.toString());
2021
totalTime = System.currentTimeMillis() - startTime;
21-
System.out.println("Created string of length " + appended.length()
22+
System.out.println("Created string of length " + appended.length()
2223
+ " in " + totalTime + " ms.");
2324
}
2425
}

java-strings-2/src/main/java/com/baeldung/localization/ICUFormat.java renamed to core-java-modules/core-java-strings/src/main/java/com/baeldung/localization/ICUFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.baeldung.localization;
22

3+
import com.ibm.icu.text.MessageFormat;
4+
35
import java.util.List;
46
import java.util.Locale;
57
import java.util.ResourceBundle;
68

7-
import com.ibm.icu.text.MessageFormat;
8-
99
public class ICUFormat {
1010

1111
public static String getLabel(Locale locale, Object[] data) {

java-strings-2/src/main/java/com/baeldung/string/multiline/MultiLineString.java renamed to core-java-modules/core-java-strings/src/main/java/com/baeldung/multiline/MultiLineString.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
package com.baeldung.string.multiline;
1+
package com.baeldung.multiline;
2+
3+
import com.google.common.base.Joiner;
4+
import com.google.common.collect.ImmutableList;
25

36
import java.io.IOException;
47
import java.io.PrintWriter;
58
import java.io.StringWriter;
69
import java.nio.file.Files;
710
import java.nio.file.Paths;
811

9-
import com.google.common.base.Joiner;
10-
import com.google.common.collect.ImmutableList;
11-
1212
public class MultiLineString {
1313

1414
String newLine = System.getProperty("line.separator");

java-strings/src/main/java/com/baeldung/string/StringPerformance.java renamed to core-java-modules/core-java-strings/src/main/java/com/baeldung/stringperformance/StringPerformance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.string;
1+
package com.baeldung.stringperformance;
22

33
import com.google.common.base.Splitter;
44
import org.apache.commons.lang3.StringUtils;

0 commit comments

Comments
 (0)