[转]Java中截取String中的多个空格成数组

转自:http://myoraclex.blog.51cto.com/2288027/578698

public class StringToArray {

  public
static void main(String args[]) {
    String s
= "北京天竺出口加工区 C1101";
    String[] arry
= s.split("\\s+");
    System.out.println(arry.length);
    System.out.println(
"arry[0]=" + arry[0]);
    System.out.println(
"arry[1]=" + arry[1]);   } }

输出:

2
arry[0]=北京天竺出口加工区
arry[1]=C1101
posted @ 2012-04-16 01:01  川川.aug  阅读(317)  评论(0编辑  收藏  举报