Move articles out of java-strings part3

This commit is contained in:
catalin-burcea
2019-10-18 17:53:04 +03:00
parent 699cc1027e
commit 9872d61b55
47 changed files with 237 additions and 90 deletions

View File

@@ -0,0 +1,16 @@
## Java String Algorithms
This module contains articles about string-related algorithms.
### Relevant Articles:
- [How to Remove the Last Character of a String?](https://www.baeldung.com/java-remove-last-character-of-string)
- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string)
- [Java Check a String for Lowercase/Uppercase Letter, Special Character and Digit](https://www.baeldung.com/java-lowercase-uppercase-special-character-digit-regex)
- [Remove or Replace Part of a String in Java](https://www.baeldung.com/java-remove-replace-string-part)
- [Replace a Character at a Specific Index in a String in Java](https://www.baeldung.com/java-replace-character-at-index)
- [Join Array of Primitives with Separator in Java](https://www.baeldung.com/java-join-primitive-array)
- [Pad a String with Zeros or Spaces in Java](https://www.baeldung.com/java-pad-string)
- [Remove Leading and Trailing Characters from a String](https://www.baeldung.com/java-remove-trailing-characters)
- [Counting Words in a String](https://www.baeldung.com/java-word-counting)
- [Finding the Difference Between Two Strings](https://www.baeldung.com/java-difference-between-two-strings)
- More articles: [[<-- prev]](../core-java-string-algorithms)

View File

@@ -0,0 +1,67 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-string-algorithms-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>core-java-string-algorithms-2</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-java</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bitbucket.cowwoc</groupId>
<artifactId>diff-match-patch</artifactId>
<version>${diff-match-path.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>core-java-string-algorithms-2</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<commons-lang3.version>3.8.1</commons-lang3.version>
<assertj.version>3.6.1</assertj.version>
<diff-match-path.version>1.2</diff-match-path.version>
</properties>
</project>

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.padding;
package com.baeldung.padding;
public class StringPaddingUtil {

View File

@@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.removelastchar;
import java.util.Optional;

View File

@@ -1,9 +1,8 @@
package com.baeldung.string.removeleadingtrailingchar;
package com.baeldung.removeleadingtrailingchar;
import org.apache.commons.lang3.StringUtils;
import com.google.common.base.CharMatcher;
import org.apache.commons.lang3.StringUtils;
public class RemoveLeadingAndTrailingZeroes {

View File

@@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.replacechar;
public class ReplaceCharacterInString {

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.wordcount;
package com.baeldung.wordcount;
import java.util.StringTokenizer;

View File

@@ -1,7 +1,7 @@
/**
*
*/
package com.baeldung.string;
package com.baeldung.addchar;
import static org.junit.Assert.assertEquals;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.join;
import com.google.common.base.Joiner;
import com.google.common.primitives.Chars;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.padding;
package com.baeldung.padding;
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;

View File

@@ -1,12 +1,12 @@
package com.baeldung.string;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
package com.baeldung.removelastchar;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
public class StringHelperUnitTest {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
public class RemoveLastCharUnitTest {
public static final String TEST_STRING = "abcdef";
public static final String NULL_STRING = null;

View File

@@ -1,13 +1,13 @@
package com.baeldung.string.removeleadingtrailingchar;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.stream.Stream;
package com.baeldung.removeleadingtrailingchar;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
public class RemoveLeadingAndTrailingZeroesUnitTest {
public static Stream<Arguments> leadingZeroTestProvider() {

View File

@@ -1,8 +1,9 @@
package com.baeldung.string;
package com.baeldung.replacechar;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
public class ReplaceCharInStringUnitTest {
private ReplaceCharacterInString characterInString = new ReplaceCharacterInString();

View File

@@ -1,7 +1,7 @@
package com.baeldung.string;
package com.baeldung.replaceremove;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import static org.junit.Assert.assertFalse;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.wordcount;
package com.baeldung.wordcount;
import static org.junit.Assert.assertEquals;

View File

@@ -0,0 +1,16 @@
## Java String Algorithms
This module contains articles about string-related algorithms.
### Relevant Articles:
- [Check If a String Is a Palindrome](https://www.baeldung.com/java-palindrome)
- [Count Occurrences of a Char in a String](https://www.baeldung.com/java-count-chars)
- [Using indexOf to Find All Occurrences of a Word in a String](https://www.baeldung.com/java-indexOf-find-string-occurrences)
- [Removing Stopwords from a String in Java](https://www.baeldung.com/java-string-remove-stopwords)
- [Removing Repeated Characters from a String](https://www.baeldung.com/java-remove-repeated-char)
- [How to Reverse a String in Java](https://www.baeldung.com/java-reverse-string)
- [Check If a String Is a Pangram in Java](https://www.baeldung.com/java-string-pangram)
- [Check If a String Contains Multiple Keywords](https://www.baeldung.com/string-contains-multiple-words)
- [Checking If a String Is a Repeated Substring](https://www.baeldung.com/java-repeated-substring)
- [Remove Emojis from a Java String](https://www.baeldung.com/java-string-remove-emojis)
- More articles: [[next -->]](../core-java-string-algorithms-2)

View File

@@ -0,0 +1,73 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-string-algorithms</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>core-java-string-algorithms</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-java</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.ahocorasick</groupId>
<artifactId>ahocorasick</artifactId>
<version>${ahocorasick.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>${emoji-java.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>core-java-string-algorithms</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<commons-lang3.version>3.8.1</commons-lang3.version>
<guava.version>27.0.1-jre</guava.version>
<ahocorasick.version>0.4.0</ahocorasick.version>
<assertj.version>3.6.1</assertj.version>
<emoji-java.version>4.0.0</emoji-java.version>
</properties>
</project>

View File

@@ -1,14 +1,12 @@
package com.baeldung.string;
package com.baeldung.matchwords;
import org.ahocorasick.trie.Emit;
import org.ahocorasick.trie.Token;
import org.ahocorasick.trie.Trie;
import java.util.*;
import java.util.function.Function;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class MatchWords {

View File

@@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.palindrom;
import java.util.stream.IntStream;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.pangram;
import java.util.Arrays;
import java.util.Map;

View File

@@ -1,4 +1,4 @@
package com.baeldung.stringduplicates;
package com.baeldung.removeduplicates;
import java.util.Arrays;
import java.util.HashSet;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.repetition;
package com.baeldung.repetition;
public class SubstringRepetition {

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.reverse;
package com.baeldung.reverse;
import org.apache.commons.lang3.StringUtils;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.searching;
package com.baeldung.searching;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,6 @@
package com.baeldung.string.performance;
package com.baeldung.stopwords;
import org.openjdk.jmh.annotations.*;
import java.io.IOException;
import java.nio.file.Files;
@@ -9,15 +11,6 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
@Fork(value = 3, warmups = 1)
@State(Scope.Benchmark)

View File

@@ -1,4 +1,4 @@
package com.baeldung.java.countingChars;
package com.baeldung.countingchars;
import static org.junit.Assert.assertEquals;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.palindrom;
import static org.junit.Assert.assertTrue;

View File

@@ -1,8 +1,9 @@
package com.baeldung.string;
package com.baeldung.pangram;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class PangramUnitTest {

View File

@@ -1,4 +1,4 @@
package com.baeldung.stringduplicates;
package com.baeldung.removeduplicates;
import org.junit.Assert;
import org.junit.Before;

View File

@@ -1,13 +1,12 @@
package com.baeldung.string;
package com.baeldung.removeemojis;
import static org.junit.Assert.assertEquals;
import com.vdurmont.emoji.EmojiParser;
import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Test;
import com.vdurmont.emoji.EmojiParser;
import static org.junit.Assert.assertEquals;
public class RemovingEmojiFromStringUnitTest {
String text = "la conférence, commencera à 10 heures 😅";

View File

@@ -1,10 +1,10 @@
package com.baeldung.string.repetition;
import static com.baeldung.string.repetition.SubstringRepetition.*;
import static org.junit.Assert.*;
package com.baeldung.repetition;
import org.junit.Test;
import static com.baeldung.repetition.SubstringRepetition.*;
import static org.junit.Assert.*;
public class SubstringRepetitionUnitTest {
private String validString = "aa";

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.reverse;
package com.baeldung.reverse;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

View File

@@ -1,4 +1,4 @@
package com.baeldung.string.searching;
package com.baeldung.searching;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

View File

@@ -1,6 +1,7 @@
package com.baeldung.string;
package com.baeldung.stopwords;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -10,8 +11,7 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class RemoveStopwordsUnitTest {
final String original = "The quick brown fox jumps over the lazy dog";

View File

@@ -6,22 +6,12 @@ This module contains articles about strings in Java.
- [Java Localization Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting)
- [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring)
- [Removing Stopwords from a String in Java](https://www.baeldung.com/java-string-remove-stopwords)
- [Java Generate Random String](https://www.baeldung.com/java-random-string)
- [Java Base64 Encoding and Decoding](https://www.baeldung.com/java-base64-encode-and-decode)
- [Removing Repeated Characters from a String](https://www.baeldung.com/java-remove-repeated-char)
- [Join Array of Primitives with Separator in Java](https://www.baeldung.com/java-join-primitive-array)
- [Pad a String with Zeros or Spaces in Java](https://www.baeldung.com/java-pad-string)
- [Remove Emojis from a Java String](https://www.baeldung.com/java-string-remove-emojis)
- [Remove Leading and Trailing Characters from a String](https://www.baeldung.com/java-remove-trailing-characters)
- [Concatenating Strings In Java](https://www.baeldung.com/java-strings-concatenation)
- [Java String Interview Questions and Answers](https://www.baeldung.com/java-string-interview-questions)
- [Check if a String is a Pangram in Java](https://www.baeldung.com/java-string-pangram)
- [Check If a String Contains Multiple Keywords](https://www.baeldung.com/string-contains-multiple-words)
- [Checking for Empty or Blank Strings in Java](https://www.baeldung.com/java-blank-empty-strings)
- [String Initialization in Java](https://www.baeldung.com/java-string-initialization)
- [Java Multi-line String](https://www.baeldung.com/java-multiline-string)
- [Checking If a String Is a Repeated Substring](https://www.baeldung.com/java-repeated-substring)
- [How to Reverse a String in Java](https://www.baeldung.com/java-reverse-string)
- [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case)
- More articles: [[<-- prev>]](/java-strings) [[next -->]](/java-strings-3)

View File

@@ -4,6 +4,4 @@ This module contains articles about strings in Java.
### Relevant Articles:
- [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase)
- [Finding the Difference Between Two Strings](https://www.baeldung.com/java-difference-between-two-strings)
- [Counting Words in a String](https://www.baeldung.com/java-word-counting)
- More articles: [[<-- prev>]](/java-strings-2)

View File

@@ -3,13 +3,9 @@
This module contains articles about operations on strings in Java.
### Relevant Articles:
- [Check If a String Is a Palindrome](https://www.baeldung.com/java-palindrome)
- [Comparing Strings in Java](https://www.baeldung.com/java-compare-strings)
- [Check If a String Is Numeric in Java](https://www.baeldung.com/java-check-string-number)
- [Get Substring from String in Java](https://www.baeldung.com/java-substring)
- [How to Remove the Last Character of a String?](https://www.baeldung.com/java-remove-last-character-of-string)
- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string)
- [Count Occurrences of a Char in a String](https://www.baeldung.com/java-count-chars)
- [Guide to Java String Pool](https://www.baeldung.com/java-string-pool)
- [Split a String in Java](https://www.baeldung.com/java-split-string)
- [Common String Operations in Java](https://www.baeldung.com/java-string-operations)

View File

@@ -90,9 +90,9 @@
<properties>
<!-- util -->
<commons-lang3.version>3.8.1</commons-lang3.version>
<guava.version>27.0.1-jre</guava.version>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>
<guava.version>27.0.1-jre</guava.version>
<junit-jupiter-api.version>5.3.1</junit-jupiter-api.version>
</properties>

View File

@@ -6,11 +6,7 @@ This module contains articles about strings in Java.
- [String Operations with Java Streams](https://www.baeldung.com/java-stream-operations-on-strings)
- [Use char[] Array Over a String for Manipulating Passwords in Java?](https://www.baeldung.com/java-storing-passwords)
- [Compact Strings in Java 9](https://www.baeldung.com/java-9-compact-string)
- [Java Check a String for Lowercase/Uppercase Letter, Special Character and Digit](https://www.baeldung.com/java-lowercase-uppercase-special-character-digit-regex)
- [String Not Empty Test Assertions in Java](https://www.baeldung.com/java-assert-string-not-empty)
- [String Performance Hints](https://www.baeldung.com/java-string-performance)
- [Using indexOf to Find All Occurrences of a Word in a String](https://www.baeldung.com/java-indexOf-find-string-occurrences)
- [Adding a Newline Character to a String in Java](https://www.baeldung.com/java-string-newline)
- [Remove or Replace Part of a String in Java](https://www.baeldung.com/java-remove-replace-string-part)
- [Replace a Character at a Specific Index in a String in Java](https://www.baeldung.com/java-replace-character-at-index)
- More articles: [[next -->]](/java-strings-2)

View File

@@ -437,6 +437,8 @@
<module>core-java-modules/core-java-sun</module>
<module>core-java-modules/core-java-string-conversions</module>
<module>core-java-modules/core-java-string-conversions-2</module>
<module>core-java-modules/core-java-string-algorithms</module>
<module>core-java-modules/core-java-string-algorithms-2</module>
<module>core-java-modules/core-java-string-apis</module>
<module>core-java-modules/core-java</module>
<module>core-java-modules/core-java-jvm</module>
@@ -1205,6 +1207,8 @@
<module>core-java-modules/core-java-sun</module>
<module>core-java-modules/core-java-string-conversions</module>
<module>core-java-modules/core-java-string-conversions-2</module>
<module>core-java-modules/core-java-string-algorithms</module>
<module>core-java-modules/core-java-string-algorithms-2</module>
<module>core-java-modules/core-java-string-apis</module>
<module>core-scala</module>
<module>couchbase</module>