Code to achieve split functionality in android

19 Jun

split function is already available in java.
for which we have to pass regularExpression and limit.
Same functionality i have tried in my way, which will give you exact result which u want.
strOriginal = pass the data here to split
strSeparator = pass the data which will split with the help of.
intMaxsize = pass the limit to get the number of resultant substrings by splitting the string.

private static String[] split(String strOriginal,String strSeparator,int intMaxsize)
		Vector<String> nodes = new Vector<String>();
		//Parse the nodes into vector
		int index = strOriginal.indexOf(strSeparator);
			nodes.addElement(strOriginal.substring(0, index));
			strOriginal = strOriginal.substring(index+strSeparator.length());
			index = strOriginal.indexOf(strSeparator);
		// Get the last node
		nodes.addElement( strOriginal );

		// Create splitted string array
		String[] result;
		result = new String[nodes.size()];

			for(int loop=0; loop<nodes.size(); loop++)
				result[loop] = (String)nodes.elementAt(loop);
				//Avoid Memory load
		return result;

Note: For more details

Leave a comment

Posted by on June 19, 2012 in Android Source Code


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: