OSCore (Open Symphony Core) is a java library with lot of utilities and reusable components. This requires the libraries oscore-2.2.6.jar, mail.jar to be in classpath. The following example shows using TextUtils.left() API.
package com.bethecoder.tutorials.oscore; import com.opensymphony.util.TextUtils; public class LeftSubstringTest { /** * @param args */ public static void main(String[] args) { String leftSubStr = TextUtils.left("abcdefghijkl", 6); System.out.println(leftSubStr); leftSubStr = TextUtils.left("abcdefghijkl", 4); System.out.println(leftSubStr); leftSubStr = TextUtils.left("abcdefghijkl", 2); System.out.println(leftSubStr); } }
abcdef abcd ab