How to parse this output and separate each field/word

前端 未结 3 853
醉话见心
醉话见心 2021-01-22 18:12

This is Akshatha. I\'m stuck in parsing the following data. I want to fetch each word individually. Can I have a sample code so that I can proceed

 RTRV-HDR   RH         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 19:00

    How about using a Stringtokenizer to fetch each word?

    import java.util.*;
    public class ReverseWords {
        public static void main( String args[] ) {
            String s = "Go to the main menu. Quick!";
            StringTokenizer tokens = new StringTokenizer(s);
            StringBuffer ab;
    
            while (tokens.hasMoreTokens()){
                ab = new StringBuffer (tokens.nextToken());
                // do your processing
            }
            System.out.println();
        }
    }
    

提交回复
热议问题