Java Code Examples for com.google.common.base.Strings.lenientFormat()

More Java code examples for com.google.common.base.Strings Guava Google Core Libraries for Java.

Java Code Example 1

import com.google.common.base.Strings;

public class StringsLenientFormatExample1 {
    public static void main(String[] args) {
        String templateString = "%s (%s) must not be negative.";
        String outputString = Strings.lenientFormat(templateString, "Ages", -1);

        System.out.println(outputString);
    }
}
Output:

Ages (-1) must not be negative.

Java Code Example 2

import com.google.common.base.Strings;

public class StringsLenientFormatExample2 {
    public static void main(String[] args) {
        String templateString = "%s (%s) must not be negative.";
        String outputString = Strings.lenientFormat(templateString, "Ages");

        System.out.println(outputString);
    }
}
Output:

Ages (%s) must not be negative.

Java Code Example 3

import com.google.common.base.Strings;

public class StringsLenientFormatExample3 {
    public static void main(String[] args) {
        String templateString = "%s %s";
        String outputString = Strings.lenientFormat(templateString, "Test", 1, 2, "Hello");

        System.out.println(outputString);
    }
}
Output:

Test 1 [2, Hello]

Java Code Example 4

import com.google.common.base.Strings;

public class StringsLenientFormatExample4 {
    public static void main(String[] args) {
        String templateString = "Simple Solution";
        String outputString = Strings.lenientFormat(templateString, "Test", 1, 2.5);

        System.out.println(outputString);
    }
}
Output:

Simple Solution [Test, 1, 2.5]