Java implementation Excel Formula special topic (iv)--string function

Source: Internet
Author: User

Directly on the code:
/** * Project Name: * File Description: EXCEL Formula Type: String Formula * Main Features: * Version number: 1.0 * Producer: Liu Morning * created: 2013-12-3 **/package excel;/** * @author LCX * */public class Stringfunctions {public static string right (string Str,int len) {if (Len>str.length ()) throw new illegal ArgumentException ("Intercept length cannot be greater than the length of the array"), Return Str.substring (Str.length ()-len, Str.length ());} public static string left (string Str,int len) {if (Len>str.length ()) throw new IllegalArgumentException ("Intercept length cannot be greater than the length of the array "); return str.substring (0, Len);} public static string mid (String Str,int Start,int len) {if (Start+len-1>str.length ()) throw new IllegalArgumentException ("intercept more Limited"); return str.substring (Start-1, start+len-1);} public static int len (String str) {if (str==null) return 0;return str.length ();} public static string concatenate (String...strs) {stringbuffer buffer=new stringbuffer (); for (String Str:strs) Buffer.append (str); return buffer.tostring ();} public static Boolean exact (String str1,string str2) {return str1.equals (STR2);} public static string upper (String str1{if (str1==null) return "", return Str1.touppercase ();} public static int Find (String find_text,string within_text,int start_num) {if (start_num<=0| | Start_num>within_text.length ()) throw new IllegalArgumentException ("start_num parameter input problem"); if (Find_text.length () >within_text.length ()) return-1; String tag=within_text.substring (start_num-1), int index=tag.indexof (find_text), if (index<0) Return-1;return Index+start_num;} public static void Main (string[] args) {/******************* test string *****************************/system.out.println ( Mid ("I Want to Program", 2,2)); System.out.println (Left ("I Want to Program", 2)); System.out.println (Right ("I Want to Program", 3)); SYSTEM.OUT.PRINTLN (Concatenate ("A", "B", "C", "D")); System.out.println (Exact (new string ("AAA"), New String ("AAA")); SYSTEM.OUT.PRINTLN (Upper ("AAAA")); System.out.println (Find ("B", "ABCABC", 3));}}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java implementation Excel Formula special topic (iv)--string function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.