StringTokenizer一个例子

package  as;
import  java.io. * ;
import  java.util. * ;
public   class  StringTokenizerText {

    
/**
     * 
@param  args
     
*/
    
public   static   void  main(String[] args) {
        
if (args.length == 0 )
            System.out.println(
" 请输入参数 " );
     
try  {
        BufferedReader br 
=   new  BufferedReader( new  InputStreamReader( new  FileInputStream(args[ 0 ])));
        BufferedWriter bw 
=   new  BufferedWriter( new  OutputStreamWriter( new  FileOutputStream(args[ 1 ])));
        PrintWriter pw 
=   new  PrintWriter(bw);
        String ii
= br.readLine();
        
        
while (ii != null )
        {
            StringTokenizer st 
=   new  StringTokenizer(ii, " = " );
            
while (st.hasMoreElements())
            {
                String c
= (String)st.nextElement();
                String b
= (String)st.nextElement();
                pw.print(c
+ " # " + b);
            }
            pw.println();
            ii
= br.readLine();
        }
        br.close();
        bw.close();
        
// pw.close();
        
        
    } 
catch  (Exception e) {
        
//  TODO Auto-generated catch block
        e.printStackTrace();
    }
     
    }

}
 

你可能感兴趣的:(StringTokenizer一个例子)