All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swiftsms.utils.HTMLParser Maven / Gradle / Ivy

Go to download

Contains reusable platform independant code for all SwiftSMS client applications.

The newest version!
package org.swiftsms.utils;

public class HTMLParser {

	/**
	 * This method is used to extract a piece of text from a String.
	 * 
	 * @param html
	 *            The larger String containing the text to be extracted.
	 * @param prefix
	 *            A unique String that occurs directly before the sought text.
	 * @param postfix
	 *            The String that occurs directly after the sought text.
	 * @return The String between the pre & post fix.
	 */
	public static String parseHtml(final String html, final String prefix, final String postfix) {
		final int startPos = html.indexOf(prefix) + prefix.length();
		final int endPos = html.indexOf(postfix, startPos);

		String targetStr = null;
		if (startPos > prefix.length()) {
			targetStr = html.substring(startPos, endPos);
		}
		return targetStr;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy