本文整理汇总了Java中org.apache.commons.lang3.text.StrTokenizer.setIgnoreEmptyTokens方法的典型用法代码示例。如果您正苦于以下问题:Java StrTokenizer.setIgnoreEmptyTokens方法的具体用法?Java StrTokenizer.setIgnoreEmptyTokens怎么用?Java StrTokenizer.setIgnoreEmptyTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.text.StrTokenizer
的用法示例。
在下文中一共展示了StrTokenizer.setIgnoreEmptyTokens方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCsvUnquoted
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
@Test
public void testCsvUnquoted() throws IOException {
StrTokenizer tokenizer = new StrTokenizer();
tokenizer.setDelimiterString(",");
tokenizer.setEmptyTokenAsNull(true);
tokenizer.setIgnoreEmptyTokens(false);
tokenizer.reset("121,432423, 9099053,Frieda karla L.,DC.,Ahrens");
String[] columns = tokenizer.getTokenArray();
assertEquals("121", columns[0]);
assertEquals("432423", columns[1]);
assertEquals(" 9099053", columns[2]);
assertEquals("Frieda karla L.", columns[3]);
assertEquals("DC.", columns[4]);
assertEquals("Ahrens", columns[5]);
tokenizer.reset(",,,,zzz ");
columns = tokenizer.getTokenArray();
assertNull(columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
}
示例2: testCsvQuoted
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
@Test
public void testCsvQuoted() throws IOException {
StrTokenizer tokenizer = new StrTokenizer();
tokenizer.setDelimiterString(",");
tokenizer.setQuoteChar('"');
tokenizer.setEmptyTokenAsNull(true);
tokenizer.setIgnoreEmptyTokens(false);
tokenizer.reset("121,432423, 9099053,\"Frieda karla L.,DC.\",Ahrens");
String[] columns = tokenizer.getTokenArray();
assertEquals("121", columns[0]);
assertEquals("432423", columns[1]);
assertEquals(" 9099053", columns[2]);
assertEquals("Frieda karla L.,DC.", columns[3]);
assertEquals("Ahrens", columns[4]);
tokenizer.reset(" ,4321");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertEquals("4321", columns[1]);
tokenizer.reset(" ,,,,zzz ");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
tokenizer.reset(",,,,zzz ");
columns = tokenizer.getTokenArray();
assertNull(columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
}
示例3: testPipes
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
@Test
public void testPipes() throws IOException {
StrTokenizer tokenizer = new StrTokenizer();
tokenizer.setDelimiterChar('|');
tokenizer.setQuoteChar('"');
tokenizer.setEmptyTokenAsNull(true);
tokenizer.setIgnoreEmptyTokens(false);
tokenizer.reset("121|432423| 9099053|\"Frieda karla L.|DC.\"|Ahrens");
String[] columns = tokenizer.getTokenArray();
assertEquals("121", columns[0]);
assertEquals("432423", columns[1]);
assertEquals(" 9099053", columns[2]);
assertEquals("Frieda karla L.|DC.", columns[3]);
assertEquals("Ahrens", columns[4]);
tokenizer.reset(" |4321");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertEquals("4321", columns[1]);
tokenizer.reset(" ||||zzz ");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
tokenizer.reset("||||zzz ");
columns = tokenizer.getTokenArray();
assertNull(columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
}
示例4: testTabQuoted
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
@Test
public void testTabQuoted() throws IOException {
StrTokenizer tokenizer = new StrTokenizer();
tokenizer.setDelimiterString("\t");
tokenizer.setQuoteChar('"');
tokenizer.setEmptyTokenAsNull(true);
tokenizer.setIgnoreEmptyTokens(false);
tokenizer.reset("121\t432423\t 9099053\t\"Frieda karla L.,DC.\"\tAhrens");
String[] columns = tokenizer.getTokenArray();
assertEquals("121", columns[0]);
assertEquals("432423", columns[1]);
assertEquals(" 9099053", columns[2]);
assertEquals("Frieda karla L.,DC.", columns[3]);
assertEquals("Ahrens", columns[4]);
tokenizer.reset(" \t4321");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertEquals("4321", columns[1]);
tokenizer.reset(" \t\t\t\tzzz ");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
tokenizer.reset("\t\t\t\tzzz ");
columns = tokenizer.getTokenArray();
assertNull(columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
}
示例5: testTabUnquoted
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
@Test
public void testTabUnquoted() throws IOException {
StrTokenizer tokenizer = new StrTokenizer();
tokenizer.setDelimiterString("\t");
tokenizer.setEmptyTokenAsNull(true);
tokenizer.setIgnoreEmptyTokens(false);
tokenizer.reset("121\t432423\t 9099053\t\"Frieda karla L.,DC.\"\tAhrens");
String[] columns = tokenizer.getTokenArray();
assertEquals("121", columns[0]);
assertEquals("432423", columns[1]);
assertEquals(" 9099053", columns[2]);
assertEquals("\"Frieda karla L.,DC.\"", columns[3]);
assertEquals("Ahrens", columns[4]);
tokenizer.reset(" \t4321");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertEquals("4321", columns[1]);
tokenizer.reset(" \t\t\t\tzzz ");
columns = tokenizer.getTokenArray();
assertEquals(" ", columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
tokenizer.reset("\t\t\t\tzzz ");
columns = tokenizer.getTokenArray();
assertNull(columns[0]);
assertNull(columns[1]);
assertNull(columns[2]);
assertNull(columns[3]);
assertEquals("zzz ", columns[4]);
}
示例6: createStrTokenizer
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
public StrTokenizer createStrTokenizer(String valueString) {
StrTokenizer tokenizer = new StrTokenizer(valueString, separator);
tokenizer.setIgnoreEmptyTokens(ignoreEmptyTokens);
tokenizer.setQuoteChar(quoteChar);
return tokenizer;
}
示例7: getFeatureSplitter
import org.apache.commons.lang3.text.StrTokenizer; //导入方法依赖的package包/类
private static StrTokenizer getFeatureSplitter(String src) {
StrTokenizer result = new StrTokenizer(src);
result.setDelimiterChar('\t');
result.setIgnoreEmptyTokens(true);
return result;
}