java 拆分出字符串中年份

【java 拆分出字符串中年份】public static void main(String[] args) {
String strInt="0123456789";
String str = "prospect 772 2009 the brawler syrah-viognier (calaveras county)";
char[] tempChar = str.toCharArray();
String year="";
int tYear=0;
int tNext=0;
String strYear="";
for(int i=0; str.length()>i; i++)
{

String s1 = String.valueOf(tempChar[i]);

if(strInt.indexOf(s1)!=-1)
{
if(tYear!=0 && (tYear+1==i) )
{
year+=s1;
tYear=i;
tNext+=1;
}
else
{
year=s1;
tYear=i;
tNext=1;

}
if(tNext==4)
{
strYear=year;
}
}

}
System.out.println(strYear);
}

    推荐阅读