java:a part:
java.util.Vector v = new Vector();//store the data
java.lang.String str = new String();//get the data from system input
char id = YOUR_NEED;//the character which be used to 
str = System.in.readLine();
while( str != null){
    
}

解决方案 »

  1.   

    java:a part:
    java.util.Vector v = new Vector();//store the data
    java.lang.String str = new String();//get the data from system input
    //the character which be used to dispart the   data
    char id = YOUR_NEED;
    str = System.in.readLine();
    String ss = new String();//the temp string 
    int pos = 0;//the position where the id come
    while( str != null){
        pos = str.indexOf(id);
        while( pos > 0 );
            v.add(new String(str.subString( 0,pos - 1 )));
            str = str.subString(pos+1,str.length());
        }
        v.add(new String(str));
    }..........try it!
      

  2.   

    呵呵,楼主,你要的完整的程序在这里:
    import java.util.StringTokenizer;
    import java.io.*;
    public class TokenTest
    {
    public static void main(String[] args)
    {
    System.out.println("input your words...");
    BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    while(true)
    {
    String s="";
    try
    {
    s=in.readLine();
    }catch(IOException e){}
    StringTokenizer st=new StringTokenizer(s);
    int c=st.countTokens();
    String[] s2=new String[c];
    //开始存入数组
    for(int i=0;i<c;i++)
    s2[i]=st.nextToken();
    //打印数组的各元素
    for(int j=0;j<s2.length;j++)
    System.out.println("array["+j+"] :"+s2[j]);
    }
    }
    }
      

  3.   

    Vector v = new Vector();
        String str = "This is a test string.I am student";
        StringTokenizer token = new StringTokenizer(str," .");
        while(token.hasMoreTokens()){
            v.add(token.nextElement());
        }
        String[] res =  new String[v.size()];
        v.toArray(res);
    注意这行 StringTokenizer token = new StringTokenizer(str," .");
    的第二个参数,可以增加到完全适合你的需要.
      

  4.   

    你们速度真快啊.我写完程序发帖子,就有这么多回复了.  xioyoo(xioyoo) 同志比我负责多了.我只给了一部分代码.
      

  5.   

    try this:import java.io.*;
    import java.util.*;public class test {
    public static void main(String args[]) {
    try {
    java.util.Vector v = new Vector();//store the data
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    while (true) {
    System.out.print("Input: ");
    String line = in.readLine();
    if(line.toLowerCase().equals("quit")) {
    System.out.println("Now Quit!");
    break;
    }
    StringTokenizer div = new StringTokenizer(line," ",false);
    while(div.hasMoreTokens()) {
    v.add(div.nextToken());
    }
    for(int i = 0;i < v.size();i++) {
    System.out.println(v.elementAt(i));
    }
    }
    } catch (Exception e) {
    System.out.println(" caught a " + e.getClass() +
     "\n with message: " + e.getMessage());
    }
    }
    }
      

  6.   

    谢谢大家啊!xioyoo(xioyoo),请问我怎么输入啊?我一运行就提示“input your words"然后就没有反应了!:)
      

  7.   

    然后你就输入一句话啊,比如:
    my name is aizhu1005
    输完之后按回车,然后程序自动显示结果
    可以无限输入