⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 superstring.java

📁 NetFlow可用于网络规划、负载均衡、安全监控等.NetFlow分析软件
💻 JAVA
字号:
package cai.utils;

import java.util.StringTokenizer;

public class SuperString {
	public String str;

	public String words[];

	public int length;

	public SuperString(String str) {
		this.str = str;

		int i = 0;

		while (i < this.str.length() && this.str.charAt(i) == ' ')
			i++;

		if (i != 0)
			if (i == this.str.length())
				this.str = new String();
			else
				this.str = this.str.substring(i);

		StringTokenizer st = new StringTokenizer(this.str);

		length = st.countTokens();
		words = new String[length];

		for (i = 0; st.hasMoreTokens(); i++)
			words[i] = st.nextToken();
	}

	public String getWord(int index) {
		return index <= length && index > 0 ? words[index - 1] : null;
	}

	public String skipWords(int count, char strip) {
		String ret;

		try {
			String str = new String(this.str);
			int index = 0;

			while (count-- > 0) {
				index = str.indexOf(' ', index);

				if (index == -1)
					throw new StringIndexOutOfBoundsException("" + index);

				while (str.charAt(++index) == ' ')
					;
			}

			ret = str.substring(index);

			if (strip != 0)
				if (ret.charAt(0) == strip)
					ret = ret.substring(1);

		} catch (StringIndexOutOfBoundsException e) {
			ret = new String();
		}

		return ret;
	}

	public String toString() {
		return str;
	}

	public static String exceptionMsg(String str) {
		int index = str.indexOf(": ");

		return index == -1 ? str : str.substring(index + 2);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -