UPDATE:分割字符串[]
输出是前人的精力:
chapter: Chapter 01
title: one
code: 111111
chapter: Chapter 02
title: two
code: 222222
chapter: Chapter 03
title: three
code: 333333
chapter: Chapter 04
title: four
code: 444444
chapter: Chapter 05
title: five
code: 555555
我有这样的代码,以分割的字符串[]。我不确定问题是什么。有人可以帮助我吗?
String[] myArray = "Chapter 01<<<one<<<111111:::Chapter 02<<<two<<<222222:::Chapter 03<<<three<<<33333:::Chapter 04<<<four<<<4444:::Chapter 05<<<five<<<5555:::"
只是为了简单起见,我必须使虚拟String[]
for (int j = 0; j < myArray.length; j++)
{
String[] songs = myArray[j].split("\\<<<");
System.out.println("chapter: " + songs[0]);
System.out.println("title: " + songs[1]);
System.out.println("code: " + songs[2]);
}
所以,我想在结果中看到的是:
chapter: Chapter 01
title: one
code: 111111
............so on and so forth........
你说你想*输出是什么,但它实际输出? – 2012-02-28 05:16:17
请发表你的输出。你得到了什么。 – joshua 2012-02-28 05:17:58
为什么不能使用StringTokenizer代替分割。它有三个构造函数可以帮助你。 – developer 2012-02-28 05:18:01