String str="I am \"you\" me for, How are, you, he for to finally ok if hello.";

解决方案 »

  1.   

    不好意思,我没说明白。实际是这样的。
    我们事先并不知道句子中的""和那些关键字会在哪里出现。所以不可能利用\。
    就比如说,
        One sweltering day, I was scooping ice cream into cones and told my four 
        children they could "buy" a cone from me for a hug. Almost immediately, the 
        kids lined up to make their purchases. The three youngest each gave me a quick 
        hug, grabbed their cones and raced back outside. But when my teen-age son 
        at the end of the line finally got his turn to "buy" his ice cream, he gave 
        me two hugs. "Keep the changes," he said with a smile.
    不可能到句子里去找""啊。因为太长了。
    象这样很长的一段话,怎么分呢?分成一个一个单词,然后用数组列表存起来。
      

  2.   

    public static void main(String[] args){
         String s = "kids lined up to make their purchases.";
         String[] words = s.split(" ");
         for(int i = 0; i < words.length; i++){
         System.out.println(words[i]);
         }
        }
      

  3.   

    用BufferedReader读出来,再存储
      

  4.   

    ??你这个string是读出来的还是自己写的?
    如果是从文件或者数据库里读的什么事都没有(或者页面传过来的话,也没关系)如果是自己写的,你不知道哪个地方有"号?
    有的话就转义就行了.
      

  5.   

    不好意思,我没说明白。实际是这样的。
    我们事先并不知道句子中的""和那些关键字会在哪里出现。所以不可能利用\。
    就比如说,
        One sweltering day, I was scooping ice cream into cones and told my four 
        children they could "buy" a cone from me for a hug. Almost immediately, the 
        kids lined up to make their purchases. The three youngest each gave me a quick 
        hug, grabbed their cones and raced back outside. But when my teen-age son 
        at the end of the line finally got his turn to "buy" his ice cream, he gave 
        me two hugs. "Keep the changes," he said with a smile.
    不可能到句子里去找""啊。因为太长了。
    象这样很长的一段话,怎么分呢?分成一个一个单词,然后用数组列表存起来。
    ——————————————————————————————————
    ??你这个string是读出来的还是自己写的?
    如果是从文件或者数据库里读的什么事都没有(或者页面传过来的话,也没关系)如果是自己写的,你不知道哪个地方有"号?
    有的话就转义就行了.
    ——————————————————————————————————
    是页面读出来的。
      

  6.   

    楼上fog628(发粪涂墙)的程序完全可以,不过有一点要指出,比如:"Keep the changes,"会被分成("Keep),(the),(changes,")
      

  7.   

    使用StringTokenizer遇到""截断字符串